home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / N-P / NString 1.0 beta.sit / NString 1.0 beta / Sources / NString.h < prev    next >
MacBinary  |  1994-11-23  |  37.3 KB  |  [TEXT/KAHL]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Wed Nov 23 21:38:38 1994, modified Wed Nov 23 21:38:38 1994, creator Think C, type ASCII, 37482 bytes "NString.h" , at 0x92ea 444 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[KAHL]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 09 4e 53 74 72 69 6e | 67 2e 68 00 00 00 00 00 |..NStrin|g.h.....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4b 41 48 | 4c 00 00 00 00 00 00 00 |.TEXTKAH|L.......|
|00000050| 00 00 00 00 00 92 6a 00 | 00 01 bc aa f9 ad 2e aa |......j.|........|
|00000060| f9 ad 2e 00 00 0e 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 c6 7d 00 00 |........|.....}..|
|00000080| 2f 2a 09 0d 0d 5f 2f 5f | 2f 5f 2f 5f 2f 5f 2f 5f |/*..._/_|/_/_/_/_|
|00000090| 2f 5f 2f 5f 2f 5f 2f 5f | 2f 5f 2f 5f 2f 5f 2f 5f |/_/_/_/_|/_/_/_/_|
|000000a0| 2f 5f 2f 5f 2f 5f 2f 5f | 2f 5f 2f 5f 2f 5f 2f 5f |/_/_/_/_|/_/_/_/_|
|000000b0| 2f 5f 2f 5f 2f 5f 2f 5f | 2f 5f 2f 5f 2f 5f 2f 5f |/_/_/_/_|/_/_/_/_|
|000000c0| 2f 0d 0d 09 09 4e 53 54 | 52 49 4e 47 20 2d 20 61 |/....NST|RING - a|
|000000d0| 20 64 79 6e 61 6d 69 63 | 20 73 74 72 69 6e 67 20 | dynamic| string |
|000000e0| 63 6c 61 73 73 20 62 61 | 73 65 64 20 6f 6e 20 74 |class ba|sed on t|
|000000f0| 68 65 20 73 74 72 69 6e | 67 20 68 61 6e 64 6c 69 |he strin|g handli|
|00000100| 6e 67 0d 09 09 09 66 75 | 6e 63 74 69 6f 6e 73 20 |ng....fu|nctions |
|00000110| 6f 66 20 74 68 65 20 4e | 45 57 54 4f 4e 20 70 72 |of the N|EWTON pr|
|00000120| 6f 67 72 61 6d 6d 69 6e | 67 20 6c 61 6e 67 75 61 |ogrammin|g langua|
|00000130| 67 65 2e 0d 09 09 09 4e | 45 57 54 4f 4e 20 69 73 |ge.....N|EWTON is|
|00000140| 20 62 65 69 6e 67 20 64 | 65 76 65 6c 6f 70 65 64 | being d|eveloped|
|00000150| 20 66 6f 72 20 56 41 58 | 2f 56 4d 53 20 61 6e 64 | for VAX|/VMS and|
|00000160| 20 44 45 43 20 41 6c 70 | 68 61 0d 09 09 09 73 79 | DEC Alp|ha....sy|
|00000170| 73 74 65 6d 73 20 62 79 | 20 74 68 65 20 73 74 61 |stems by| the sta|
|00000180| 66 66 20 6f 66 20 74 68 | 65 20 63 6f 6d 70 69 6c |ff of th|e compil|
|00000190| 61 74 69 6f 6e 20 6c 61 | 62 20 28 4c 43 4f 29 20 |ation la|b (LCO) |
|000001a0| 6f 66 20 74 68 65 0d 09 | 09 09 53 77 69 73 73 20 |of the..|..Swiss |
|000001b0| 46 65 64 65 72 61 6c 20 | 49 6e 73 74 69 74 75 74 |Federal |Institut|
|000001c0| 65 20 6f 66 20 54 65 63 | 68 6e 6f 6c 6f 67 79 20 |e of Tec|hnology |
|000001d0| 28 45 50 46 4c 29 2e 0d | 0d 09 09 56 65 72 73 69 |(EPFL)..|...Versi|
|000001e0| 6f 6e 20 31 2e 30 20 2d | 20 62 65 74 61 0d 09 09 |on 1.0 -| beta...|
|000001f0| 0d 09 09 43 6f 70 79 72 | 69 67 68 74 20 a9 20 32 |...Copyr|ight . 2|
|00000200| 30 74 68 20 4e 6f 76 65 | 6d 62 65 72 2c 20 31 39 |0th Nove|mber, 19|
|00000210| 39 34 20 62 79 20 4a 6f | 91 6c 20 22 4f 62 69 77 |94 by Jo|.l "Obiw|
|00000220| 61 6e 22 20 46 72 61 6e | 8d 6f 69 73 0d 0d 5f 2f |an" Fran|.ois.._/|
|00000230| 5f 2f 5f 2f 5f 2f 5f 2f | 5f 2f 5f 2f 5f 2f 5f 2f |_/_/_/_/|_/_/_/_/|
|00000240| 5f 2f 5f 2f 5f 2f 5f 2f | 5f 2f 5f 2f 5f 2f 5f 2f |_/_/_/_/|_/_/_/_/|
|00000250| 5f 2f 5f 2f 5f 2f 5f 2f | 5f 2f 5f 2f 5f 2f 5f 2f |_/_/_/_/|_/_/_/_/|
|00000260| 5f 2f 5f 2f 5f 2f 5f 2f | 5f 2f 0d 0d 2a 2f 0d 0d |_/_/_/_/|_/..*/..|
|00000270| 23 69 66 6e 64 65 66 20 | 5f 4e 53 54 52 49 4e 47 |#ifndef |_NSTRING|
|00000280| 5f 48 5f 0d 23 64 65 66 | 69 6e 65 20 5f 4e 53 54 |_H_.#def|ine _NST|
|00000290| 52 49 4e 47 5f 48 5f 0d | 0d 23 69 6e 63 6c 75 64 |RING_H_.|.#includ|
|000002a0| 65 20 3c 69 6f 73 74 72 | 65 61 6d 2e 68 3e 0d 23 |e <iostr|eam.h>.#|
|000002b0| 69 6e 63 6c 75 64 65 20 | 22 41 6c 70 68 61 62 65 |include |"Alphabe|
|000002c0| 74 2e 68 22 0d 0d 63 6c | 61 73 73 20 4e 53 74 72 |t.h"..cl|ass NStr|
|000002d0| 69 6e 67 0d 7b 0d 09 70 | 75 62 6c 69 63 3a 0d 0d |ing.{..p|ublic:..|
|000002e0| 09 09 2f 2f 20 4e 4f 54 | 45 3a 20 55 6e 6c 65 73 |..// NOT|E: Unles|
|000002f0| 73 20 6f 74 68 65 72 77 | 69 73 65 20 73 70 65 63 |s otherw|ise spec|
|00000300| 69 66 69 65 64 2c 20 74 | 68 65 20 72 65 66 65 72 |ified, t|he refer|
|00000310| 65 6e 63 65 20 72 65 74 | 75 72 6e 65 64 20 62 79 |ence ret|urned by|
|00000320| 20 66 75 6e 63 74 69 6f | 6e 73 20 74 68 61 74 20 | functio|ns that |
|00000330| 72 65 74 75 72 6e 0d 09 | 09 2f 2f 20 09 61 6e 20 |return..|.// .an |
|00000340| 4e 53 74 72 69 6e 67 26 | 20 69 73 20 61 6c 77 61 |NString&| is alwa|
|00000350| 79 73 20 61 20 72 65 66 | 65 72 65 6e 63 65 20 74 |ys a ref|erence t|
|00000360| 6f 20 74 68 65 20 63 75 | 72 72 65 6e 74 20 4e 53 |o the cu|rrent NS|
|00000370| 74 72 69 6e 67 20 6f 62 | 6a 65 63 74 2c 20 74 6f |tring ob|ject, to|
|00000380| 20 61 6c 6c 6f 77 20 63 | 6f 6e 63 61 74 65 6e 61 | allow c|oncatena|
|00000390| 74 69 6f 6e 0d 09 09 2f | 2f 09 09 6f 66 20 4e 53 |tion.../|/..of NS|
|000003a0| 74 72 69 6e 67 20 6f 70 | 65 72 61 74 69 6f 6e 73 |tring op|erations|
|000003b0| 2e 0d 0d 0d 09 09 2f 2a | 2d 2d 2d 2d 2d 2d 2d 2d |....../*|--------|
|000003c0| 20 50 75 62 6c 69 63 20 | 43 6f 6e 73 74 72 75 63 | Public |Construc|
|000003d0| 74 6f 72 73 20 26 20 44 | 65 73 74 72 75 63 74 6f |tors & D|estructo|
|000003e0| 72 20 2d 2d 2d 2d 2d 2d | 2d 2d 2a 2f 0d 0d 09 09 |r ------|--*/....|
|000003f0| 4e 53 74 72 69 6e 67 20 | 28 76 6f 69 64 29 3b 09 |NString |(void);.|
|00000400| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 09 |........|........|
|00000410| 09 09 2f 2f 09 09 4e 53 | 74 72 69 6e 67 20 73 3b |..//..NS|tring s;|
|00000420| 0d 09 09 09 2f 2f 20 63 | 6f 6e 73 74 72 75 63 74 |....// c|onstruct|
|00000430| 6f 72 3a 20 63 72 65 61 | 74 65 20 61 6e 20 65 6d |or: crea|te an em|
|00000440| 70 74 79 20 4e 53 74 72 | 69 6e 67 2e 0d 09 09 0d |pty NStr|ing.....|
|00000450| 09 09 4e 53 74 72 69 6e | 67 20 28 63 6f 6e 73 74 |..NStrin|g (const|
|00000460| 20 63 68 61 72 20 2a 73 | 29 3b 09 09 09 09 09 09 | char *s|);......|
|00000470| 09 09 09 09 09 09 09 09 | 09 09 2f 2f 09 09 4e 53 |........|..//..NS|
|00000480| 74 72 69 6e 67 20 73 28 | 22 48 65 6c 6c 6f 20 57 |tring s(|"Hello W|
|00000490| 6f 72 6c 64 22 29 3b 0d | 09 09 09 2f 2f 20 63 6f |orld");.|...// co|
|000004a0| 6e 73 74 72 75 63 74 6f | 72 3a 20 4e 53 74 72 69 |nstructo|r: NStri|
|000004b0| 6e 67 20 69 6e 69 74 69 | 61 6c 69 7a 65 64 20 77 |ng initi|alized w|
|000004c0| 69 74 68 20 61 20 67 69 | 76 65 6e 20 43 2d 53 74 |ith a gi|ven C-St|
|000004d0| 72 69 6e 67 2e 0d 0d 09 | 09 4e 53 74 72 69 6e 67 |ring....|.NString|
|000004e0| 20 28 63 6f 6e 73 74 20 | 63 68 61 72 20 63 29 3b | (const |char c);|
|000004f0| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 09 09 09 |........|........|
|00000500| 2f 2f 09 09 4e 53 74 72 | 69 6e 67 20 73 28 27 50 |//..NStr|ing s('P|
|00000510| 27 29 3b 0d 09 09 09 2f | 2f 20 63 6f 6e 73 74 72 |');..../|/ constr|
|00000520| 75 63 74 6f 72 3a 20 4e | 53 74 72 69 6e 67 20 69 |uctor: N|String i|
|00000530| 6e 69 74 69 61 6c 69 7a | 65 64 20 77 69 74 68 20 |nitializ|ed with |
|00000540| 61 20 63 68 61 72 61 63 | 74 65 72 2e 0d 09 09 09 |a charac|ter.....|
|00000550| 2f 2f 20 49 66 20 74 68 | 65 20 63 68 61 72 61 63 |// If th|e charac|
|00000560| 74 65 72 20 69 73 20 61 | 20 4e 55 4c 20 63 68 61 |ter is a| NUL cha|
|00000570| 72 61 63 74 65 72 2c 20 | 61 20 72 75 6e 74 69 6d |racter, |a runtim|
|00000580| 65 20 65 72 72 6f 72 20 | 77 69 6c 6c 20 62 65 20 |e error |will be |
|00000590| 72 61 69 73 65 64 2e 0d | 09 09 0d 09 09 69 6e 6c |raised..|.....inl|
|000005a0| 69 6e 65 20 4e 53 74 72 | 69 6e 67 20 28 63 6f 6e |ine NStr|ing (con|
|000005b0| 73 74 20 4e 53 74 72 69 | 6e 67 26 20 73 29 3b 09 |st NStri|ng& s);.|
|000005c0| 09 09 09 09 09 09 09 09 | 09 09 09 2f 2f 09 09 4e |........|...//..N|
|000005d0| 53 74 72 69 6e 67 20 73 | 28 61 29 3b 0d 09 09 09 |String s|(a);....|
|000005e0| 2f 2f 20 63 6f 6e 73 74 | 72 75 63 74 6f 72 3a 20 |// const|ructor: |
|000005f0| 4e 53 74 72 69 6e 67 20 | 63 6f 70 69 65 64 20 66 |NString |copied f|
|00000600| 72 6f 6d 20 61 6e 20 65 | 78 69 73 74 69 6e 67 20 |rom an e|xisting |
|00000610| 4e 53 74 72 69 6e 67 2e | 0d 09 09 09 0d 09 09 7e |NString.|.......~|
|00000620| 4e 53 74 72 69 6e 67 20 | 28 76 6f 69 64 29 3b 0d |NString |(void);.|
|00000630| 09 09 09 2f 2f 20 64 65 | 73 74 72 75 63 74 6f 72 |...// de|structor|
|00000640| 0d 0d 09 09 2f 2a 2d 2d | 2d 2d 2d 2d 2d 2d 20 41 |..../*--|------ A|
|00000650| 73 73 69 67 6e 6d 65 6e | 74 20 2d 2d 2d 2d 2d 2d |ssignmen|t ------|
|00000660| 2d 2d 2a 2f 0d 0d 09 09 | 4e 53 74 72 69 6e 67 26 |--*/....|NString&|
|00000670| 20 6f 70 65 72 61 74 6f | 72 3d 20 28 63 6f 6e 73 | operato|r= (cons|
|00000680| 74 20 63 68 61 72 20 2a | 73 29 3b 09 09 09 09 09 |t char *|s);.....|
|00000690| 09 09 09 09 09 09 2f 2f | 09 09 73 20 3d 20 22 48 |......//|..s = "H|
|000006a0| 65 6c 6c 6f 20 57 6f 72 | 6c 64 22 3b 0d 09 09 09 |ello Wor|ld";....|
|000006b0| 2f 2f 20 62 75 69 6c 64 | 20 61 6e 20 4e 53 74 72 |// build| an NStr|
|000006c0| 69 6e 67 20 66 72 6f 6d | 20 61 20 43 2d 53 74 72 |ing from| a C-Str|
|000006d0| 69 6e 67 0d 0d 09 09 4e | 53 74 72 69 6e 67 26 20 |ing....N|String& |
|000006e0| 6f 70 65 72 61 74 6f 72 | 3d 20 28 63 6f 6e 73 74 |operator|= (const|
|000006f0| 20 63 68 61 72 20 63 29 | 3b 09 09 09 09 09 09 09 | char c)|;.......|
|00000700| 09 09 09 09 09 2f 2f 09 | 09 73 20 3d 20 27 4d 27 |.....//.|.s = 'M'|
|00000710| 3b 0d 09 09 09 2f 2f 20 | 62 75 69 6c 64 20 61 6e |;....// |build an|
|00000720| 20 4e 53 74 72 69 6e 67 | 20 66 72 6f 6d 20 61 20 | NString| from a |
|00000730| 63 68 61 72 61 63 74 65 | 72 0d 09 09 09 2f 2f 20 |characte|r....// |
|00000740| 49 66 20 74 68 65 20 63 | 68 61 72 61 63 74 65 72 |If the c|haracter|
|00000750| 20 69 73 20 61 20 4e 55 | 4c 20 63 68 61 72 61 63 | is a NU|L charac|
|00000760| 74 65 72 2c 20 61 20 72 | 75 6e 74 69 6d 65 20 65 |ter, a r|untime e|
|00000770| 72 72 6f 72 20 77 69 6c | 6c 20 62 65 20 72 61 69 |rror wil|l be rai|
|00000780| 73 65 64 2e 0d 09 09 09 | 0d 09 09 4e 53 74 72 69 |sed.....|...NStri|
|00000790| 6e 67 26 20 6f 70 65 72 | 61 74 6f 72 3d 20 28 63 |ng& oper|ator= (c|
|000007a0| 6f 6e 73 74 20 4e 53 74 | 72 69 6e 67 26 20 73 29 |onst NSt|ring& s)|
|000007b0| 3b 09 09 09 09 09 09 09 | 09 09 09 2f 2f 09 09 73 |;.......|...//..s|
|000007c0| 20 3d 20 74 3b 0d 09 09 | 09 2f 2f 20 63 6f 70 79 | = t;...|.// copy|
|000007d0| 20 61 6e 20 4e 53 74 72 | 69 6e 67 0d 0d 09 09 2f | an NStr|ing..../|
|000007e0| 2a 2d 2d 2d 2d 2d 2d 2d | 2d 20 47 65 74 74 69 6e |*-------|- Gettin|
|000007f0| 67 20 61 74 20 74 68 65 | 20 69 6e 66 6f 72 6d 61 |g at the| informa|
|00000800| 74 69 6f 6e 20 63 6f 6e | 74 61 69 6e 65 64 20 69 |tion con|tained i|
|00000810| 6e 20 61 6e 20 4e 53 74 | 72 69 6e 67 20 2d 2d 2d |n an NSt|ring ---|
|00000820| 2d 2d 2d 2d 2d 2a 2f 0d | 09 09 0d 09 09 63 68 61 |-----*/.|.....cha|
|00000830| 72 20 2a 73 74 72 69 6e | 67 20 28 76 6f 69 64 29 |r *strin|g (void)|
|00000840| 20 63 6f 6e 73 74 3b 09 | 09 09 09 09 09 09 09 09 | const;.|........|
|00000850| 09 09 09 09 09 09 2f 2f | 09 09 43 5f 73 74 72 20 |......//|..C_str |
|00000860| 3d 20 73 2e 73 74 72 69 | 6e 67 63 6f 70 79 28 29 |= s.stri|ngcopy()|
|00000870| 3b 0d 09 09 09 2f 2f 20 | 67 65 74 20 61 20 63 6f |;....// |get a co|
|00000880| 70 79 20 6f 66 20 74 68 | 65 20 43 2d 53 74 72 69 |py of th|e C-Stri|
|00000890| 6e 67 20 63 6f 6e 74 61 | 69 6e 65 64 20 69 6e 20 |ng conta|ined in |
|000008a0| 74 68 65 20 4e 53 74 72 | 69 6e 67 2e 0d 09 09 09 |the NStr|ing.....|
|000008b0| 2f 2f 20 4e 4f 54 45 3a | 20 59 6f 75 20 6d 75 73 |// NOTE:| You mus|
|000008c0| 74 20 66 72 65 65 28 29 | 20 74 68 65 20 72 65 74 |t free()| the ret|
|000008d0| 75 72 6e 65 64 20 70 6f | 69 6e 74 65 72 20 61 66 |urned po|inter af|
|000008e0| 74 65 72 20 75 73 61 67 | 65 2e 0d 09 09 09 0d 09 |ter usag|e.......|
|000008f0| 09 69 6e 6c 69 6e 65 20 | 63 68 61 72 20 2a 73 74 |.inline |char *st|
|00000900| 72 69 6e 67 20 28 63 68 | 61 72 20 2a 73 29 20 63 |ring (ch|ar *s) c|
|00000910| 6f 6e 73 74 3b 09 09 09 | 09 09 09 09 09 09 09 09 |onst;...|........|
|00000920| 09 2f 2f 09 09 73 2e 73 | 74 72 69 6e 67 28 43 5f |.//..s.s|tring(C_|
|00000930| 73 74 72 29 3b 0d 09 09 | 09 2f 2f 20 67 65 74 20 |str);...|.// get |
|00000940| 61 20 63 6f 70 79 20 6f | 66 20 74 68 65 20 43 2d |a copy o|f the C-|
|00000950| 53 74 72 69 6e 67 20 63 | 6f 6e 74 61 69 6e 65 64 |String c|ontained|
|00000960| 20 69 6e 20 74 68 65 20 | 4e 53 74 72 69 6e 67 2e | in the |NString.|
|00000970| 0d 09 09 09 2f 2f 20 54 | 68 65 20 70 72 6f 76 69 |....// T|he provi|
|00000980| 64 65 64 20 63 68 61 72 | 20 70 6f 69 6e 74 65 72 |ded char| pointer|
|00000990| 20 69 73 20 75 73 65 64 | 20 74 6f 20 73 74 6f 72 | is used| to stor|
|000009a0| 65 20 74 68 65 20 63 6f | 70 79 2e 0d 09 09 09 2f |e the co|py...../|
|000009b0| 2f 20 57 41 52 4e 49 4e | 47 3a 20 54 68 65 20 70 |/ WARNIN|G: The p|
|000009c0| 72 6f 76 69 64 65 64 20 | 62 75 66 66 65 72 20 6d |rovided |buffer m|
|000009d0| 75 73 74 20 62 65 20 6c | 61 72 67 65 20 65 6e 6f |ust be l|arge eno|
|000009e0| 75 67 68 0d 09 09 09 2f | 2f 20 74 6f 20 68 6f 6c |ugh..../|/ to hol|
|000009f0| 64 20 74 68 65 20 73 74 | 72 69 6e 67 3b 20 6e 6f |d the st|ring; no|
|00000a00| 20 62 6f 75 6e 64 61 72 | 79 20 63 68 65 63 6b 73 | boundar|y checks|
|00000a10| 20 61 72 65 20 64 6f 6e | 65 20 21 0d 0d 09 09 2f | are don|e !..../|
|00000a20| 2f 20 4e 4f 54 45 3a 20 | 54 68 65 20 73 74 72 69 |/ NOTE: |The stri|
|00000a30| 6e 67 28 29 20 66 75 6e | 63 74 69 6f 6e 73 20 72 |ng() fun|ctions r|
|00000a40| 65 74 75 72 6e 20 73 6f | 6c 65 6c 79 20 61 20 43 |eturn so|lely a C|
|00000a50| 4f 50 59 20 6f 66 20 74 | 68 65 20 43 2d 73 74 72 |OPY of t|he C-str|
|00000a60| 69 6e 67 20 63 6f 6e 74 | 61 69 6e 65 64 20 69 6e |ing cont|ained in|
|00000a70| 20 74 68 65 20 4e 53 74 | 72 69 6e 67 2e 0d 09 09 | the NSt|ring....|
|00000a80| 2f 2f 09 09 49 74 20 69 | 73 20 4e 4f 54 20 70 6f |//..It i|s NOT po|
|00000a90| 73 73 69 62 6c 65 20 74 | 6f 20 72 65 74 75 72 6e |ssible t|o return|
|00000aa0| 20 61 20 70 6f 69 6e 74 | 65 72 20 74 6f 20 74 68 | a point|er to th|
|00000ab0| 65 20 6f 72 69 67 69 6e | 61 6c 20 73 74 72 69 6e |e origin|al strin|
|00000ac0| 67 2c 20 61 73 20 74 68 | 69 73 20 70 6f 69 6e 74 |g, as th|is point|
|00000ad0| 65 72 20 6d 69 67 68 74 | 20 63 68 61 6e 67 65 0d |er might| change.|
|00000ae0| 09 09 2f 2f 09 09 64 75 | 72 69 6e 67 20 73 75 62 |..//..du|ring sub|
|00000af0| 73 65 71 75 65 6e 74 20 | 4e 53 74 72 69 6e 67 2d |sequent |NString-|
|00000b00| 6f 70 65 72 61 74 69 6f | 6e 73 20 21 20 20 4d 6f |operatio|ns ! Mo|
|00000b10| 72 65 6f 76 65 72 2c 20 | 74 68 69 73 20 77 61 79 |reover, |this way|
|00000b20| 20 74 68 65 20 63 6c 61 | 73 73 20 75 73 65 72 20 | the cla|ss user |
|00000b30| 63 61 6e 6e 6f 74 0d 09 | 09 2f 2f 09 09 63 6f 72 |cannot..|.//..cor|
|00000b40| 72 75 70 74 20 63 6c 61 | 73 73 20 69 6e 74 65 67 |rupt cla|ss integ|
|00000b50| 72 69 74 79 20 62 79 20 | 6d 6f 64 69 66 79 69 6e |rity by |modifyin|
|00000b60| 67 20 73 74 72 69 6e 67 | 20 64 61 74 61 20 64 69 |g string| data di|
|00000b70| 72 65 63 74 6c 79 2e 0d | 0d 09 09 69 6e 6c 69 6e |rectly..|...inlin|
|00000b80| 65 20 75 6e 73 69 67 6e | 65 64 20 6c 6f 6e 67 20 |e unsign|ed long |
|00000b90| 69 6e 74 20 6c 65 6e 67 | 74 68 20 28 76 6f 69 64 |int leng|th (void|
|00000ba0| 29 20 63 6f 6e 73 74 3b | 09 09 09 09 09 09 09 09 |) const;|........|
|00000bb0| 09 2f 2f 09 09 6c 20 3d | 20 73 2e 6c 65 6e 67 74 |.//..l =| s.lengt|
|00000bc0| 68 28 29 3b 0d 09 09 09 | 2f 2f 20 67 65 74 20 74 |h();....|// get t|
|00000bd0| 68 65 20 6c 65 6e 67 74 | 68 20 6f 66 20 74 68 65 |he lengt|h of the|
|00000be0| 20 4e 53 74 72 69 6e 67 | 0d 0d 09 09 2f 2a 2d 2d | NString|..../*--|
|00000bf0| 2d 2d 2d 2d 2d 2d 20 41 | 63 63 65 73 73 69 6e 67 |------ A|ccessing|
|00000c00| 20 73 69 6e 67 6c 65 20 | 63 68 61 72 61 63 74 65 | single |characte|
|00000c10| 72 73 20 69 6e 20 74 68 | 65 20 4e 53 74 72 69 6e |rs in th|e NStrin|
|00000c20| 67 20 2d 2d 2d 2d 2d 2d | 2d 2d 2a 2f 0d 0d 09 09 |g ------|--*/....|
|00000c30| 63 68 61 72 20 6f 70 65 | 72 61 74 6f 72 5b 5d 20 |char ope|rator[] |
|00000c40| 28 63 6f 6e 73 74 20 75 | 6e 73 69 67 6e 65 64 20 |(const u|nsigned |
|00000c50| 6c 6f 6e 67 20 69 6e 74 | 20 6b 29 20 63 6f 6e 73 |long int| k) cons|
|00000c60| 74 3b 09 09 09 09 09 09 | 09 2f 2f 09 09 63 20 3d |t;......|.//..c =|
|00000c70| 20 73 5b 33 5d 3b 0d 09 | 09 09 2f 2f 20 72 65 61 | s[3];..|..// rea|
|00000c80| 64 20 74 68 65 20 6b 74 | 68 20 63 68 61 72 61 63 |d the kt|h charac|
|00000c90| 74 65 72 20 6f 66 20 74 | 68 65 20 4e 53 74 72 69 |ter of t|he NStri|
|00000ca0| 6e 67 3b 20 73 5b 31 5d | 20 69 73 20 74 68 65 20 |ng; s[1]| is the |
|00000cb0| 66 69 72 73 74 20 63 68 | 61 72 61 63 74 65 72 3b |first ch|aracter;|
|00000cc0| 0d 09 09 09 2f 2f 20 69 | 66 20 28 6b 20 3e 20 73 |....// i|f (k > s|
|00000cd0| 2e 6c 65 6e 67 74 68 29 | 20 61 20 72 75 6e 74 69 |.length)| a runti|
|00000ce0| 6d 65 20 65 72 72 6f 72 | 20 77 69 6c 6c 20 6f 63 |me error| will oc|
|00000cf0| 63 75 72 2e 0d 09 09 09 | 2f 2f 20 54 68 75 73 20 |cur.....|// Thus |
|00000d00| 74 68 65 20 74 65 72 6d | 69 6e 61 74 69 6e 67 20 |the term|inating |
|00000d10| 4e 55 4c 2d 62 79 74 65 | 20 63 61 6e 27 74 20 62 |NUL-byte| can't b|
|00000d20| 65 20 72 65 61 64 2e 0d | 09 09 09 0d 09 09 63 68 |e read..|......ch|
|00000d30| 61 72 20 73 65 74 63 68 | 61 72 20 28 63 6f 6e 73 |ar setch|ar (cons|
|00000d40| 74 20 75 6e 73 69 67 6e | 65 64 20 6c 6f 6e 67 20 |t unsign|ed long |
|00000d50| 69 6e 74 20 6b 2c 20 63 | 6f 6e 73 74 20 63 68 61 |int k, c|onst cha|
|00000d60| 72 20 63 29 3b 09 09 09 | 09 09 09 2f 2f 09 09 73 |r c);...|...//..s|
|00000d70| 2e 73 65 74 63 68 61 72 | 28 32 2c 20 27 51 27 29 |.setchar|(2, 'Q')|
|00000d80| 3b 0d 09 09 09 2f 2f 20 | 6d 6f 64 69 66 79 20 74 |;....// |modify t|
|00000d90| 68 65 20 6b 74 68 20 63 | 68 61 72 61 63 74 65 72 |he kth c|haracter|
|00000da0| 20 6f 66 20 74 68 65 20 | 4e 53 74 72 69 6e 67 3b | of the |NString;|
|00000db0| 20 74 68 65 20 66 69 72 | 73 74 20 63 68 61 72 61 | the fir|st chara|
|00000dc0| 63 74 65 72 20 69 73 20 | 6e 75 6d 62 65 72 65 64 |cter is |numbered|
|00000dd0| 20 31 3b 0d 09 09 09 2f | 2f 20 69 66 20 28 6b 20 | 1;..../|/ if (k |
|00000de0| 3e 20 73 2e 6c 65 6e 67 | 74 68 29 20 61 20 72 75 |> s.leng|th) a ru|
|00000df0| 6e 74 69 6d 65 20 65 72 | 72 6f 72 20 77 69 6c 6c |ntime er|ror will|
|00000e00| 20 6f 63 63 75 72 2e 20 | 54 68 75 73 20 74 68 65 | occur. |Thus the|
|00000e10| 20 74 65 72 6d 69 6e 61 | 74 69 6e 67 20 4e 55 4c | termina|ting NUL|
|00000e20| 2d 62 79 74 65 20 63 61 | 6e 27 74 20 62 65 20 6d |-byte ca|n't be m|
|00000e30| 6f 64 69 66 69 65 64 2e | 0d 09 09 09 2f 2f 20 54 |odified.|....// T|
|00000e40| 68 69 73 20 69 73 20 6e | 65 63 65 73 73 61 72 79 |his is n|ecessary|
|00000e50| 20 74 6f 20 70 72 65 76 | 65 6e 74 20 63 6f 72 72 | to prev|ent corr|
|00000e60| 75 70 74 69 6f 6e 20 6f | 66 20 74 68 65 20 4e 53 |uption o|f the NS|
|00000e70| 74 72 69 6e 67 20 62 79 | 20 61 6c 74 65 72 69 6e |tring by| alterin|
|00000e80| 67 20 69 74 27 73 20 74 | 65 72 6d 69 6e 61 74 6f |g it's t|erminato|
|00000e90| 72 2e 0d 09 09 09 2f 2f | 20 41 6c 73 6f 2c 20 69 |r.....//| Also, i|
|00000ea0| 66 20 28 63 20 3d 3d 20 | 27 5c 30 27 29 20 61 20 |f (c == |'\0') a |
|00000eb0| 72 75 6e 74 69 6d 65 20 | 65 72 72 6f 72 20 77 69 |runtime |error wi|
|00000ec0| 6c 6c 20 62 65 20 72 61 | 69 73 65 64 2c 20 61 73 |ll be ra|ised, as|
|00000ed0| 20 70 6c 61 63 69 6e 67 | 20 61 20 4e 55 4c 20 63 | placing| a NUL c|
|00000ee0| 68 61 72 61 63 74 65 72 | 20 69 6e 20 74 68 65 20 |haracter| in the |
|00000ef0| 6d 69 64 64 6c 65 0d 09 | 09 09 2f 2f 09 09 6f 66 |middle..|..//..of|
|00000f00| 20 74 68 65 20 4e 53 74 | 72 69 6e 67 20 77 6f 75 | the NSt|ring wou|
|00000f10| 6c 64 20 63 6f 72 72 75 | 70 74 20 69 74 2e 0d 09 |ld corru|pt it...|
|00000f20| 09 09 2f 2f 20 54 68 65 | 20 72 65 74 75 72 6e 20 |..// The| return |
|00000f30| 76 61 6c 75 65 20 69 73 | 20 74 68 65 20 63 68 61 |value is| the cha|
|00000f40| 72 61 63 74 65 72 20 74 | 68 61 74 20 66 6f 72 6d |racter t|hat form|
|00000f50| 65 72 6c 79 20 72 65 73 | 69 64 65 64 20 61 74 20 |erly res|ided at |
|00000f60| 69 6e 64 65 78 20 6b 20 | 69 6e 20 74 68 65 20 4e |index k |in the N|
|00000f70| 53 74 72 69 6e 67 2e 0d | 0d 09 09 2f 2a 2d 2d 2d |String..|.../*---|
|00000f80| 2d 2d 2d 2d 2d 20 43 6f | 6d 70 61 72 69 6e 67 20 |----- Co|mparing |
|00000f90| 4e 53 74 72 69 6e 67 73 | 20 2d 2d 2d 2d 2d 2d 2d |NStrings| -------|
|00000fa0| 2d 2a 2f 0d 0d 09 09 69 | 6e 6c 69 6e 65 20 69 6e |-*/....i|nline in|
|00000fb0| 74 20 6f 70 65 72 61 74 | 6f 72 3d 3d 20 28 63 6f |t operat|or== (co|
|00000fc0| 6e 73 74 20 63 68 61 72 | 20 2a 73 29 20 63 6f 6e |nst char| *s) con|
|00000fd0| 73 74 3b 09 09 09 09 09 | 09 09 09 09 2f 2f 09 09 |st;.....|....//..|
|00000fe0| 69 66 20 28 73 20 3d 3d | 20 22 59 65 73 22 29 20 |if (s ==| "Yes") |
|00000ff0| 2e 2e 2e 3b 0d 0d 09 09 | 69 6e 6c 69 6e 65 20 69 |...;....|inline i|
|00001000| 6e 74 20 6f 70 65 72 61 | 74 6f 72 21 3d 20 28 63 |nt opera|tor!= (c|
|00001010| 6f 6e 73 74 20 63 68 61 | 72 20 2a 73 29 20 63 6f |onst cha|r *s) co|
|00001020| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 09 2f 2f 09 |nst;....|.....//.|
|00001030| 09 69 66 20 28 73 20 21 | 3d 20 22 4e 6f 22 29 20 |.if (s !|= "No") |
|00001040| 2e 2e 2e 3b 0d 0d 09 09 | 69 6e 6c 69 6e 65 20 69 |...;....|inline i|
|00001050| 6e 74 20 6f 70 65 72 61 | 74 6f 72 3e 3d 20 28 63 |nt opera|tor>= (c|
|00001060| 6f 6e 73 74 20 63 68 61 | 72 20 2a 73 29 20 63 6f |onst cha|r *s) co|
|00001070| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 09 2f 2f 09 |nst;....|.....//.|
|00001080| 09 69 66 20 28 73 20 3e | 3d 20 22 61 6c 70 68 61 |.if (s >|= "alpha|
|00001090| 22 29 20 2e 2e 2e 3b 0d | 0d 09 09 69 6e 6c 69 6e |") ...;.|...inlin|
|000010a0| 65 20 69 6e 74 20 6f 70 | 65 72 61 74 6f 72 3c 3d |e int op|erator<=|
|000010b0| 20 28 63 6f 6e 73 74 20 | 63 68 61 72 20 2a 73 29 | (const |char *s)|
|000010c0| 20 63 6f 6e 73 74 3b 09 | 09 09 09 09 09 09 09 09 | const;.|........|
|000010d0| 2f 2f 09 09 69 66 20 28 | 73 20 3c 3d 20 22 62 65 |//..if (|s <= "be|
|000010e0| 74 61 22 29 20 2e 2e 2e | 3b 0d 0d 09 09 69 6e 6c |ta") ...|;....inl|
|000010f0| 69 6e 65 20 69 6e 74 20 | 6f 70 65 72 61 74 6f 72 |ine int |operator|
|00001100| 3e 20 28 63 6f 6e 73 74 | 20 63 68 61 72 20 2a 73 |> (const| char *s|
|00001110| 29 20 63 6f 6e 73 74 3b | 09 09 09 09 09 09 09 09 |) const;|........|
|00001120| 09 09 2f 2f 09 09 69 66 | 20 28 73 20 3e 20 22 61 |..//..if| (s > "a|
|00001130| 6c 70 68 61 22 29 20 2e | 2e 2e 3b 0d 0d 09 09 69 |lpha") .|..;....i|
|00001140| 6e 6c 69 6e 65 20 69 6e | 74 20 6f 70 65 72 61 74 |nline in|t operat|
|00001150| 6f 72 3c 20 28 63 6f 6e | 73 74 20 63 68 61 72 20 |or< (con|st char |
|00001160| 2a 73 29 20 63 6f 6e 73 | 74 3b 09 09 09 09 09 09 |*s) cons|t;......|
|00001170| 09 09 09 09 2f 2f 09 09 | 69 66 20 28 73 20 3c 20 |....//..|if (s < |
|00001180| 22 62 65 74 61 22 29 20 | 2e 2e 2e 3b 0d 0d 09 09 |"beta") |...;....|
|00001190| 69 6e 6c 69 6e 65 20 69 | 6e 74 20 63 6f 6d 70 61 |inline i|nt compa|
|000011a0| 72 65 20 28 63 6f 6e 73 | 74 20 63 68 61 72 20 2a |re (cons|t char *|
|000011b0| 73 29 20 63 6f 6e 73 74 | 3b 09 09 09 09 09 09 09 |s) const|;.......|
|000011c0| 09 09 09 2f 2f 09 09 69 | 66 20 28 73 2e 63 6f 6d |...//..i|f (s.com|
|000011d0| 70 61 72 65 28 22 48 65 | 6c 6c 6f 22 29 20 3d 3d |pare("He|llo") ==|
|000011e0| 20 30 29 20 2e 2e 2e 3b | 0d 09 09 09 2f 2f 20 73 | 0) ...;|....// s|
|000011f0| 69 6d 70 6c 79 20 72 65 | 74 75 72 6e 73 20 74 68 |imply re|turns th|
|00001200| 65 20 72 65 73 75 6c 74 | 20 6f 66 20 73 74 72 63 |e result| of strc|
|00001210| 6d 70 28 29 0d 09 09 09 | 2f 2f 09 09 7a 65 72 6f |mp()....|//..zero|
|00001220| 20 6d 65 61 6e 73 20 28 | 2a 74 68 69 73 20 3d 3d | means (|*this ==|
|00001230| 20 73 29 0d 09 09 09 2f | 2f 09 09 67 72 65 61 74 | s)..../|/..great|
|00001240| 65 72 20 74 68 61 6e 20 | 7a 65 72 6f 20 6d 65 61 |er than |zero mea|
|00001250| 6e 73 20 28 2a 74 68 69 | 73 20 3e 20 73 29 0d 09 |ns (*thi|s > s)..|
|00001260| 09 09 2f 2f 09 09 6c 65 | 73 73 20 74 68 61 6e 20 |..//..le|ss than |
|00001270| 7a 65 72 6f 20 6d 65 61 | 6e 73 20 28 2a 74 68 69 |zero mea|ns (*thi|
|00001280| 73 20 3c 20 73 29 0d 0d | 09 09 69 6e 6c 69 6e 65 |s < s)..|..inline|
|00001290| 20 69 6e 74 20 6f 70 65 | 72 61 74 6f 72 3d 3d 20 | int ope|rator== |
|000012a0| 28 63 6f 6e 73 74 20 4e | 53 74 72 69 6e 67 26 20 |(const N|String& |
|000012b0| 73 29 20 63 6f 6e 73 74 | 3b 09 09 09 09 09 09 09 |s) const|;.......|
|000012c0| 09 2f 2f 09 09 69 66 20 | 28 73 20 3d 3d 20 74 29 |.//..if |(s == t)|
|000012d0| 20 2e 2e 2e 3b 0d 0d 09 | 09 69 6e 6c 69 6e 65 20 | ...;...|.inline |
|000012e0| 69 6e 74 20 6f 70 65 72 | 61 74 6f 72 21 3d 20 28 |int oper|ator!= (|
|000012f0| 63 6f 6e 73 74 20 4e 53 | 74 72 69 6e 67 26 20 73 |const NS|tring& s|
|00001300| 29 20 63 6f 6e 73 74 3b | 09 09 09 09 09 09 09 09 |) const;|........|
|00001310| 2f 2f 09 09 69 66 20 28 | 73 20 21 3d 20 74 29 20 |//..if (|s != t) |
|00001320| 2e 2e 2e 3b 0d 0d 09 09 | 69 6e 6c 69 6e 65 20 69 |...;....|inline i|
|00001330| 6e 74 20 6f 70 65 72 61 | 74 6f 72 3e 3d 20 28 63 |nt opera|tor>= (c|
|00001340| 6f 6e 73 74 20 4e 53 74 | 72 69 6e 67 26 20 73 29 |onst NSt|ring& s)|
|00001350| 20 63 6f 6e 73 74 3b 09 | 09 09 09 09 09 09 09 2f | const;.|......./|
|00001360| 2f 09 09 69 66 20 28 73 | 20 3e 3d 20 74 29 20 2e |/..if (s| >= t) .|
|00001370| 2e 2e 3b 0d 0d 09 09 69 | 6e 6c 69 6e 65 20 69 6e |..;....i|nline in|
|00001380| 74 20 6f 70 65 72 61 74 | 6f 72 3c 3d 20 28 63 6f |t operat|or<= (co|
|00001390| 6e 73 74 20 4e 53 74 72 | 69 6e 67 26 20 73 29 20 |nst NStr|ing& s) |
|000013a0| 63 6f 6e 73 74 3b 09 09 | 09 09 09 09 09 09 2f 2f |const;..|......//|
|000013b0| 09 09 69 66 20 28 73 20 | 3c 3d 20 74 29 20 2e 2e |..if (s |<= t) ..|
|000013c0| 2e 3b 0d 0d 09 09 69 6e | 6c 69 6e 65 20 69 6e 74 |.;....in|line int|
|000013d0| 20 6f 70 65 72 61 74 6f | 72 3e 20 28 63 6f 6e 73 | operato|r> (cons|
|000013e0| 74 20 4e 53 74 72 69 6e | 67 26 20 73 29 20 63 6f |t NStrin|g& s) co|
|000013f0| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 2f 2f 09 09 |nst;....|....//..|
|00001400| 69 66 20 28 73 20 3e 20 | 74 29 20 2e 2e 2e 3b 0d |if (s > |t) ...;.|
|00001410| 0d 09 09 69 6e 6c 69 6e | 65 20 69 6e 74 20 6f 70 |...inlin|e int op|
|00001420| 65 72 61 74 6f 72 3c 20 | 28 63 6f 6e 73 74 20 4e |erator< |(const N|
|00001430| 53 74 72 69 6e 67 26 20 | 73 29 20 63 6f 6e 73 74 |String& |s) const|
|00001440| 3b 09 09 09 09 09 09 09 | 09 2f 2f 09 09 69 66 20 |;.......|.//..if |
|00001450| 28 73 20 3c 20 74 29 20 | 2e 2e 2e 3b 0d 0d 09 09 |(s < t) |...;....|
|00001460| 69 6e 6c 69 6e 65 20 69 | 6e 74 20 63 6f 6d 70 61 |inline i|nt compa|
|00001470| 72 65 20 28 63 6f 6e 73 | 74 20 4e 53 74 72 69 6e |re (cons|t NStrin|
|00001480| 67 26 20 73 29 20 63 6f | 6e 73 74 3b 09 09 09 09 |g& s) co|nst;....|
|00001490| 09 09 09 09 09 2f 2f 09 | 09 69 66 20 28 73 2e 63 |.....//.|.if (s.c|
|000014a0| 6f 6d 70 61 72 65 28 74 | 29 20 21 3d 20 30 29 20 |ompare(t|) != 0) |
|000014b0| 2e 2e 2e 3b 0d 09 09 09 | 2f 2f 20 73 69 6d 70 6c |...;....|// simpl|
|000014c0| 79 20 72 65 74 75 72 6e | 73 20 74 68 65 20 72 65 |y return|s the re|
|000014d0| 73 75 6c 74 20 6f 66 20 | 73 74 72 63 6d 70 28 29 |sult of |strcmp()|
|000014e0| 0d 09 09 09 2f 2f 09 09 | 7a 65 72 6f 20 6d 65 61 |....//..|zero mea|
|000014f0| 6e 73 20 28 2a 74 68 69 | 73 20 3d 3d 20 73 29 0d |ns (*thi|s == s).|
|00001500| 09 09 09 2f 2f 09 09 67 | 72 65 61 74 65 72 20 74 |...//..g|reater t|
|00001510| 68 61 6e 20 7a 65 72 6f | 20 6d 65 61 6e 73 20 28 |han zero| means (|
|00001520| 2a 74 68 69 73 20 3e 20 | 73 29 0d 09 09 09 2f 2f |*this > |s)....//|
|00001530| 09 09 6c 65 73 73 20 74 | 68 61 6e 20 7a 65 72 6f |..less t|han zero|
|00001540| 20 6d 65 61 6e 73 20 28 | 2a 74 68 69 73 20 3c 20 | means (|*this < |
|00001550| 73 29 0d 0d 09 09 69 6e | 6c 69 6e 65 20 69 6e 74 |s)....in|line int|
|00001560| 20 6f 70 65 72 61 74 6f | 72 3d 3d 20 28 63 6f 6e | operato|r== (con|
|00001570| 73 74 20 63 68 61 72 20 | 63 29 20 63 6f 6e 73 74 |st char |c) const|
|00001580| 3b 09 09 09 09 09 09 09 | 09 09 2f 2f 09 09 69 66 |;.......|..//..if|
|00001590| 20 28 73 20 3d 3d 20 27 | 52 27 29 20 2e 2e 2e 3b | (s == '|R') ...;|
|000015a0| 0d 0d 09 09 69 6e 6c 69 | 6e 65 20 69 6e 74 20 6f |....inli|ne int o|
|000015b0| 70 65 72 61 74 6f 72 21 | 3d 20 28 63 6f 6e 73 74 |perator!|= (const|
|000015c0| 20 63 68 61 72 20 63 29 | 20 63 6f 6e 73 74 3b 09 | char c)| const;.|
|000015d0| 09 09 09 09 09 09 09 09 | 09 2f 2f 09 09 69 66 20 |........|.//..if |
|000015e0| 28 73 20 21 3d 20 27 4c | 27 29 20 2e 2e 2e 3b 0d |(s != 'L|') ...;.|
|000015f0| 0d 09 09 69 6e 6c 69 6e | 65 20 69 6e 74 20 6f 70 |...inlin|e int op|
|00001600| 65 72 61 74 6f 72 3e 3d | 20 28 63 6f 6e 73 74 20 |erator>=| (const |
|00001610| 63 68 61 72 20 63 29 20 | 63 6f 6e 73 74 3b 09 09 |char c) |const;..|
|00001620| 09 09 09 09 09 09 09 09 | 2f 2f 09 09 69 66 20 28 |........|//..if (|
|00001630| 73 20 3e 3d 20 27 41 27 | 29 20 2e 2e 2e 3b 0d 0d |s >= 'A'|) ...;..|
|00001640| 09 09 69 6e 6c 69 6e 65 | 20 69 6e 74 20 6f 70 65 |..inline| int ope|
|00001650| 72 61 74 6f 72 3c 3d 20 | 28 63 6f 6e 73 74 20 63 |rator<= |(const c|
|00001660| 68 61 72 20 63 29 20 63 | 6f 6e 73 74 3b 09 09 09 |har c) c|onst;...|
|00001670| 09 09 09 09 09 09 09 2f | 2f 09 09 69 66 20 28 73 |......./|/..if (s|
|00001680| 20 3c 3d 20 27 42 27 29 | 20 2e 2e 2e 3b 0d 0d 09 | <= 'B')| ...;...|
|00001690| 09 69 6e 6c 69 6e 65 20 | 69 6e 74 20 6f 70 65 72 |.inline |int oper|
|000016a0| 61 74 6f 72 3e 20 28 63 | 6f 6e 73 74 20 63 68 61 |ator> (c|onst cha|
|000016b0| 72 20 63 29 20 63 6f 6e | 73 74 3b 09 09 09 09 09 |r c) con|st;.....|
|000016c0| 09 09 09 09 09 2f 2f 09 | 09 69 66 20 28 73 20 3e |.....//.|.if (s >|
|000016d0| 20 27 41 27 29 20 2e 2e | 2e 3b 0d 0d 09 09 69 6e | 'A') ..|.;....in|
|000016e0| 6c 69 6e 65 20 69 6e 74 | 20 6f 70 65 72 61 74 6f |line int| operato|
|000016f0| 72 3c 20 28 63 6f 6e 73 | 74 20 63 68 61 72 20 63 |r< (cons|t char c|
|00001700| 29 20 63 6f 6e 73 74 3b | 09 09 09 09 09 09 09 09 |) const;|........|
|00001710| 09 09 2f 2f 09 09 69 66 | 20 28 73 20 3c 20 27 42 |..//..if| (s < 'B|
|00001720| 27 29 20 2e 2e 2e 3b 0d | 0d 09 09 69 6e 6c 69 6e |') ...;.|...inlin|
|00001730| 65 20 69 6e 74 20 63 6f | 6d 70 61 72 65 20 28 63 |e int co|mpare (c|
|00001740| 6f 6e 73 74 20 63 68 61 | 72 20 63 29 20 63 6f 6e |onst cha|r c) con|
|00001750| 73 74 3b 09 09 09 09 09 | 09 09 09 09 09 09 2f 2f |st;.....|......//|
|00001760| 09 09 69 66 20 28 73 2e | 63 6f 6d 70 61 72 65 28 |..if (s.|compare(|
|00001770| 27 4e 27 29 20 3d 3d 20 | 30 29 20 2e 2e 2e 3b 0d |'N') == |0) ...;.|
|00001780| 09 09 09 2f 2f 09 09 30 | 09 09 6d 65 61 6e 73 20 |...//..0|..means |
|00001790| 28 2a 74 68 69 73 20 3d | 3d 20 63 29 0d 09 09 09 |(*this =|= c)....|
|000017a0| 2f 2f 09 09 31 09 09 6d | 65 61 6e 73 20 28 2a 74 |//..1..m|eans (*t|
|000017b0| 68 69 73 20 3e 20 73 29 | 0d 09 09 09 2f 2f 09 09 |his > s)|....//..|
|000017c0| 2d 31 09 6d 65 61 6e 73 | 20 28 2a 74 68 69 73 20 |-1.means| (*this |
|000017d0| 3c 20 73 29 0d 0d 0d 09 | 09 69 6e 6c 69 6e 65 20 |< s)....|.inline |
|000017e0| 63 6f 6e 73 74 20 4e 53 | 74 72 69 6e 67 26 20 6d |const NS|tring& m|
|000017f0| 69 6e 20 28 63 6f 6e 73 | 74 20 4e 53 74 72 69 6e |in (cons|t NStrin|
|00001800| 67 26 20 6f 74 68 65 72 | 29 20 63 6f 6e 73 74 3b |g& other|) const;|
|00001810| 09 09 09 09 09 2f 2f 09 | 09 74 20 3d 20 73 2e 6d |.....//.|.t = s.m|
|00001820| 69 6e 28 4e 53 74 72 69 | 6e 67 28 22 68 65 6c 70 |in(NStri|ng("help|
|00001830| 22 29 29 3b 0d 09 09 09 | 2f 2f 09 72 65 74 75 72 |"));....|//.retur|
|00001840| 6e 20 74 68 69 73 20 4e | 53 74 72 69 6e 67 20 69 |n this N|String i|
|00001850| 66 20 28 2a 74 68 69 73 | 20 3c 20 6f 74 68 65 72 |f (*this| < other|
|00001860| 29 2c 20 22 6f 74 68 65 | 72 22 20 6f 74 68 65 72 |), "othe|r" other|
|00001870| 77 69 73 65 2e 0d 0d 09 | 09 69 6e 6c 69 6e 65 20 |wise....|.inline |
|00001880| 63 6f 6e 73 74 20 4e 53 | 74 72 69 6e 67 26 20 6d |const NS|tring& m|
|00001890| 61 78 20 28 63 6f 6e 73 | 74 20 4e 53 74 72 69 6e |ax (cons|t NStrin|
|000018a0| 67 26 20 6f 74 68 65 72 | 29 20 63 6f 6e 73 74 3b |g& other|) const;|
|000018b0| 09 09 09 09 09 2f 2f 09 | 09 74 20 3d 20 73 2e 6d |.....//.|.t = s.m|
|000018c0| 61 78 28 74 29 3b 0d 09 | 09 09 2f 2f 09 72 65 74 |ax(t);..|..//.ret|
|000018d0| 75 72 6e 20 74 68 69 73 | 20 4e 53 74 72 69 6e 67 |urn this| NString|
|000018e0| 20 69 66 20 28 2a 74 68 | 69 73 20 3e 20 6f 74 68 | if (*th|is > oth|
|000018f0| 65 72 29 2c 20 22 6f 74 | 68 65 72 22 20 6f 74 68 |er), "ot|her" oth|
|00001900| 65 72 77 69 73 65 0d 0d | 09 09 2f 2a 2d 2d 2d 2d |erwise..|../*----|
|00001910| 2d 2d 2d 2d 20 43 6f 6e | 63 61 74 65 6e 61 74 69 |---- Con|catenati|
|00001920| 6e 67 20 4e 53 74 72 69 | 6e 67 73 20 2d 2d 2d 2d |ng NStri|ngs ----|
|00001930| 2d 2d 2d 2d 2a 2f 0d 0d | 09 09 2f 2f 20 4e 6f 74 |----*/..|..// Not|
|00001940| 65 3a 20 41 6e 20 61 74 | 74 65 6d 70 74 20 74 6f |e: An at|tempt to|
|00001950| 20 61 64 64 20 61 20 4e | 55 4c 20 63 68 61 72 61 | add a N|UL chara|
|00001960| 63 74 65 72 20 74 6f 20 | 61 6e 20 4e 53 74 72 69 |cter to |an NStri|
|00001970| 6e 67 20 77 69 6c 6c 20 | 61 6c 77 61 79 73 20 72 |ng will |always r|
|00001980| 65 73 75 6c 74 20 69 6e | 20 61 20 72 75 6e 74 69 |esult in| a runti|
|00001990| 6d 65 20 65 72 72 6f 72 | 2e 0d 0d 09 09 4e 53 74 |me error|.....NSt|
|000019a0| 72 69 6e 67 26 20 6f 70 | 65 72 61 74 6f 72 2b 3d |ring& op|erator+=|
|000019b0| 20 28 63 6f 6e 73 74 20 | 63 68 61 72 20 2a 73 29 | (const |char *s)|
|000019c0| 3b 09 09 09 09 09 09 09 | 09 09 09 09 2f 2f 09 09 |;.......|....//..|
|000019d0| 73 20 2b 3d 20 22 2e 74 | 78 74 22 3b 0d 09 09 09 |s += ".t|xt";....|
|000019e0| 2f 2f 20 65 78 74 65 6e | 64 20 61 6e 20 4e 53 74 |// exten|d an NSt|
|000019f0| 72 69 6e 67 20 62 79 20 | 61 64 64 69 6e 67 20 61 |ring by |adding a|
|00001a00| 20 43 2d 53 74 72 69 6e | 67 0d 0d 09 09 4e 53 74 | C-Strin|g....NSt|
|00001a10| 72 69 6e 67 26 20 6f 70 | 65 72 61 74 6f 72 2b 3d |ring& op|erator+=|
|00001a20| 20 28 63 6f 6e 73 74 20 | 4e 53 74 72 69 6e 67 26 | (const |NString&|
|00001a30| 20 73 29 3b 09 09 09 09 | 09 09 09 09 09 09 2f 2f | s);....|......//|
|00001a40| 09 09 73 20 2b 3d 20 74 | 3b 0d 09 09 09 2f 2f 20 |..s += t|;....// |
|00001a50| 65 78 74 65 6e 64 20 61 | 6e 20 4e 53 74 72 69 6e |extend a|n NStrin|
|00001a60| 67 20 62 79 20 61 64 64 | 69 6e 67 20 61 6e 6f 74 |g by add|ing anot|
|00001a70| 68 65 72 20 4e 53 74 72 | 69 6e 67 0d 0d 09 09 4e |her NStr|ing....N|
|00001a80| 53 74 72 69 6e 67 26 20 | 6f 70 65 72 61 74 6f 72 |String& |operator|
|00001a90| 2b 3d 20 28 63 6f 6e 73 | 74 20 63 68 61 72 20 63 |+= (cons|t char c|
|00001aa0| 29 3b 09 09 09 09 09 09 | 09 09 09 09 09 2f 2f 09 |);......|.....//.|
|00001ab0| 09 73 20 2b 3d 20 27 63 | 27 3b 0d 09 09 09 2f 2f |.s += 'c|';....//|
|00001ac0| 20 65 78 74 65 6e 64 20 | 61 6e 20 4e 53 74 72 69 | extend |an NStri|
|00001ad0| 6e 67 20 62 79 20 61 64 | 64 69 6e 67 20 61 20 63 |ng by ad|ding a c|
|00001ae0| 68 61 72 61 63 74 65 72 | 0d 0d 09 09 4e 53 74 72 |haracter|....NStr|
|00001af0| 69 6e 67 20 6f 70 65 72 | 61 74 6f 72 2b 20 28 63 |ing oper|ator+ (c|
|00001b00| 6f 6e 73 74 20 63 68 61 | 72 20 2a 73 29 20 63 6f |onst cha|r *s) co|
|00001b10| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 09 09 2f 2f |nst;....|......//|
|00001b20| 09 09 75 20 3d 20 73 20 | 2b 20 22 2e 73 69 74 22 |..u = s |+ ".sit"|
|00001b30| 3b 0d 09 09 09 2f 2f 20 | 63 72 65 61 74 65 20 61 |;....// |create a|
|00001b40| 20 6e 65 77 20 4e 53 74 | 72 69 6e 67 20 74 68 61 | new NSt|ring tha|
|00001b50| 74 20 69 73 20 74 68 65 | 20 63 6f 6e 63 61 74 65 |t is the| concate|
|00001b60| 6e 61 74 69 6f 6e 20 6f | 66 0d 09 09 09 2f 2f 09 |nation o|f....//.|
|00001b70| 09 61 6e 20 4e 53 74 72 | 69 6e 67 20 77 69 74 68 |.an NStr|ing with|
|00001b80| 20 61 20 43 2d 53 74 72 | 69 6e 67 0d 0d 09 09 4e | a C-Str|ing....N|
|00001b90| 53 74 72 69 6e 67 20 6f | 70 65 72 61 74 6f 72 2b |String o|perator+|
|00001ba0| 20 28 4e 53 74 72 69 6e | 67 26 20 73 29 20 63 6f | (NStrin|g& s) co|
|00001bb0| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 09 09 09 2f |nst;....|......./|
|00001bc0| 2f 09 09 75 20 3d 20 73 | 20 2b 20 74 3b 0d 09 09 |/..u = s| + t;...|
|00001bd0| 09 2f 2f 20 63 72 65 61 | 74 65 20 61 20 6e 65 77 |.// crea|te a new|
|00001be0| 20 4e 53 74 72 69 6e 67 | 20 74 68 61 74 20 69 73 | NString| that is|
|00001bf0| 20 74 68 65 20 63 6f 6e | 63 61 74 65 6e 61 74 69 | the con|catenati|
|00001c00| 6f 6e 20 6f 66 0d 09 09 | 09 2f 2f 09 09 74 77 6f |on of...|.//..two|
|00001c10| 20 4e 53 74 72 69 6e 67 | 73 0d 0d 09 09 4e 53 74 | NString|s....NSt|
|00001c20| 72 69 6e 67 20 6f 70 65 | 72 61 74 6f 72 2b 20 28 |ring ope|rator+ (|
|00001c30| 63 6f 6e 73 74 20 63 68 | 61 72 20 63 29 20 63 6f |const ch|ar c) co|
|00001c40| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 09 09 2f 2f |nst;....|......//|
|00001c50| 09 09 75 20 3d 20 73 20 | 2b 20 27 4d 27 3b 0d 09 |..u = s |+ 'M';..|
|00001c60| 09 09 2f 2f 20 63 72 65 | 61 74 65 20 61 20 6e 65 |..// cre|ate a ne|
|00001c70| 77 20 4e 53 74 72 69 6e | 67 20 74 68 61 74 20 69 |w NStrin|g that i|
|00001c80| 73 20 74 68 65 20 63 6f | 6e 63 61 74 65 6e 61 74 |s the co|ncatenat|
|00001c90| 69 6f 6e 20 6f 66 0d 09 | 09 09 2f 2f 09 09 61 6e |ion of..|..//..an|
|00001ca0| 20 4e 53 74 72 69 6e 67 | 20 77 69 74 68 20 61 20 | NString| with a |
|00001cb0| 63 68 61 72 61 63 74 65 | 72 0d 0d 09 09 66 72 69 |characte|r....fri|
|00001cc0| 65 6e 64 20 4e 53 74 72 | 69 6e 67 20 6f 70 65 72 |end NStr|ing oper|
|00001cd0| 61 74 6f 72 2b 20 28 63 | 6f 6e 73 74 20 63 68 61 |ator+ (c|onst cha|
|00001ce0| 72 20 2a 73 2c 20 63 6f | 6e 73 74 20 4e 53 74 72 |r *s, co|nst NStr|
|00001cf0| 69 6e 67 26 20 6e 73 29 | 3b 09 09 09 2f 2f 20 09 |ing& ns)|;...// .|
|00001d00| 73 20 3d 20 22 2a 2a 2a | 22 20 2b 20 74 3b 0d 09 |s = "***|" + t;..|
|00001d10| 09 09 2f 2f 20 66 6f 72 | 6d 20 61 20 6e 65 77 20 |..// for|m a new |
|00001d20| 4e 53 74 72 69 6e 67 20 | 62 79 20 69 6e 73 65 72 |NString |by inser|
|00001d30| 74 69 6e 67 20 61 20 43 | 2d 53 74 72 69 6e 67 20 |ting a C|-String |
|00001d40| 61 74 20 74 68 65 0d 09 | 09 09 2f 2f 09 09 62 65 |at the..|..//..be|
|00001d50| 67 69 6e 6e 69 6e 67 20 | 6f 66 20 61 6e 20 4e 53 |ginning |of an NS|
|00001d60| 74 72 69 6e 67 2e 0d 0d | 09 09 66 72 69 65 6e 64 |tring...|..friend|
|00001d70| 20 4e 53 74 72 69 6e 67 | 20 6f 70 65 72 61 74 6f | NString| operato|
|00001d80| 72 2b 20 28 63 6f 6e 73 | 74 20 63 68 61 72 20 63 |r+ (cons|t char c|
|00001d90| 2c 20 63 6f 6e 73 74 20 | 4e 53 74 72 69 6e 67 26 |, const |NString&|
|00001da0| 20 6e 73 29 3b 09 09 09 | 2f 2f 20 09 73 20 3d 20 | ns);...|// .s = |
|00001db0| 27 3e 27 20 2b 20 74 3b | 0d 09 09 09 2f 2f 20 66 |'>' + t;|....// f|
|00001dc0| 6f 72 6d 20 61 20 6e 65 | 77 20 4e 53 74 72 69 6e |orm a ne|w NStrin|
|00001dd0| 67 20 62 79 20 61 64 64 | 69 6e 67 20 61 20 63 68 |g by add|ing a ch|
|00001de0| 61 72 61 63 74 65 72 20 | 74 6f 20 74 68 65 0d 09 |aracter |to the..|
|00001df0| 09 09 2f 2f 09 09 62 65 | 67 69 6e 6e 69 6e 67 20 |..//..be|ginning |
|00001e00| 6f 66 20 61 6e 20 4e 53 | 74 72 69 6e 67 2e 0d 0d |of an NS|tring...|
|00001e10| 09 09 4e 53 74 72 69 6e | 67 26 20 6f 70 65 72 61 |..NStrin|g& opera|
|00001e20| 74 6f 72 2a 3d 20 28 63 | 6f 6e 73 74 20 75 6e 73 |tor*= (c|onst uns|
|00001e30| 69 67 6e 65 64 20 6c 6f | 6e 67 20 69 6e 74 20 6b |igned lo|ng int k|
|00001e40| 29 3b 09 09 09 09 09 09 | 09 2f 2f 20 09 73 20 2a |);......|.// .s *|
|00001e50| 3d 20 32 3b 0d 09 09 09 | 2f 2f 20 63 68 61 6e 67 |= 2;....|// chang|
|00001e60| 65 20 74 68 65 20 4e 53 | 74 72 69 6e 67 20 74 6f |e the NS|tring to|
|00001e70| 20 6b 20 74 69 6d 65 73 | 20 69 74 73 20 6f 72 69 | k times| its ori|
|00001e80| 67 69 6e 61 6c 20 73 74 | 72 69 6e 67 0d 09 09 09 |ginal st|ring....|
|00001e90| 2f 2f 20 6b 3d 3d 30 20 | 72 65 73 75 6c 74 73 20 |// k==0 |results |
|00001ea0| 69 6e 20 61 6e 20 65 6d | 70 74 79 20 73 74 72 69 |in an em|pty stri|
|00001eb0| 6e 67 3b 20 6b 3d 3d 31 | 20 6c 65 61 76 65 73 20 |ng; k==1| leaves |
|00001ec0| 74 68 65 20 4e 53 74 72 | 69 6e 67 20 75 6e 63 68 |the NStr|ing unch|
|00001ed0| 61 6e 67 65 64 0d 09 09 | 09 0d 09 09 4e 53 74 72 |anged...|....NStr|
|00001ee0| 69 6e 67 20 6f 70 65 72 | 61 74 6f 72 2a 20 28 63 |ing oper|ator* (c|
|00001ef0| 6f 6e 73 74 20 75 6e 73 | 69 67 6e 65 64 20 6c 6f |onst uns|igned lo|
|00001f00| 6e 67 20 69 6e 74 20 6b | 29 20 63 6f 6e 73 74 3b |ng int k|) const;|
|00001f10| 09 09 09 09 09 09 2f 2f | 09 09 73 20 3d 20 74 20 |......//|..s = t |
|00001f20| 2a 20 33 3b 0d 09 09 09 | 2f 2f 20 62 75 69 6c 64 |* 3;....|// build|
|00001f30| 20 61 20 6e 65 77 20 4e | 53 74 72 69 6e 67 20 63 | a new N|String c|
|00001f40| 6f 6e 73 69 73 74 69 6e | 67 20 6f 66 20 74 68 65 |onsistin|g of the|
|00001f50| 20 6f 72 69 67 69 6e 61 | 6c 20 73 74 72 69 6e 67 | origina|l string|
|00001f60| 20 6b 20 74 69 6d 65 73 | 20 63 6f 6e 63 61 74 65 | k times| concate|
|00001f70| 6e 61 74 65 64 0d 09 09 | 09 2f 2f 20 6b 3d 3d 30 |nated...|.// k==0|
|00001f80| 20 72 65 73 75 6c 74 73 | 20 69 6e 20 61 6e 20 65 | results| in an e|
|00001f90| 6d 70 74 79 20 73 74 72 | 69 6e 67 3b 20 6b 3d 3d |mpty str|ing; k==|
|00001fa0| 31 20 72 65 74 75 72 6e | 73 20 61 20 63 6f 70 79 |1 return|s a copy|
|00001fb0| 20 6f 66 20 74 68 65 20 | 6f 72 69 67 69 6e 61 6c | of the |original|
|00001fc0| 20 4e 53 74 72 69 6e 67 | 0d 0d 09 09 2f 2a 2d 2d | NString|..../*--|
|00001fd0| 2d 2d 2d 2d 2d 2d 20 43 | 6f 70 79 69 6e 67 20 70 |------ C|opying p|
|00001fe0| 61 72 74 73 20 6f 66 20 | 61 6e 20 4e 53 74 72 69 |arts of |an NStri|
|00001ff0| 6e 67 20 2d 2d 2d 2d 2d | 2d 2d 2d 2a 2f 0d 0d 09 |ng -----|---*/...|
|00002000| 09 4e 53 74 72 69 6e 67 | 20 66 72 6f 6d 74 6f 20 |.NString| fromto |
|00002010| 28 75 6e 73 69 67 6e 65 | 64 20 6c 6f 6e 67 20 69 |(unsigne|d long i|
|00002020| 6e 74 20 66 72 6f 6d 2c | 20 75 6e 73 69 67 6e 65 |nt from,| unsigne|
|00002030| 64 20 6c 6f 6e 67 20 69 | 6e 74 20 74 6f 29 20 63 |d long i|nt to) c|
|00002040| 6f 6e 73 74 3b 09 2f 2f | 09 09 74 20 3d 20 73 2e |onst;.//|..t = s.|
|00002050| 66 72 6f 6d 74 6f 28 32 | 2c 35 29 0d 09 09 09 2f |fromto(2|,5)..../|
|00002060| 2f 20 72 65 74 75 72 6e | 20 61 6e 20 4e 53 74 72 |/ return| an NStr|
|00002070| 69 6e 67 20 63 6f 6e 73 | 69 73 74 69 6e 67 20 6f |ing cons|isting o|
|00002080| 66 20 74 68 65 20 73 75 | 62 73 74 72 69 6e 67 20 |f the su|bstring |
|00002090| 6f 66 20 74 68 65 20 6f | 72 69 67 69 6e 61 6c 20 |of the o|riginal |
|000020a0| 4e 53 74 72 69 6e 67 0d | 09 09 09 2f 2f 20 72 61 |NString.|...// ra|
|000020b0| 6e 67 69 6e 67 20 66 72 | 6f 6d 20 63 68 61 72 61 |nging fr|om chara|
|000020c0| 63 74 65 72 20 23 20 22 | 66 72 6f 6d 22 20 74 6f |cter # "|from" to|
|000020d0| 20 63 68 61 72 61 63 74 | 65 72 20 23 20 22 74 6f | charact|er # "to|
|000020e0| 22 2e 0d 09 09 09 2f 2f | 20 54 68 65 20 66 69 72 |".....//| The fir|
|000020f0| 73 74 20 63 68 61 72 61 | 63 74 65 72 20 69 73 20 |st chara|cter is |
|00002100| 63 6f 75 6e 74 65 64 20 | 61 73 20 23 20 31 2c 20 |counted |as # 1, |
|00002110| 74 68 65 20 6c 61 73 74 | 20 61 73 20 23 20 73 2e |the last| as # s.|
|00002120| 6c 65 6e 67 74 68 28 29 | 2e 0d 09 09 09 2f 2f 20 |length()|.....// |
|00002130| 42 6f 74 68 20 6f 66 20 | 74 68 65 20 62 6f 72 64 |Both of |the bord|
|00002140| 65 72 20 63 68 61 72 61 | 63 74 65 72 73 20 61 72 |er chara|cters ar|
|00002150| 65 20 69 6e 63 6c 75 64 | 65 64 20 69 6e 20 74 68 |e includ|ed in th|
|00002160| 65 20 6e 65 77 20 73 74 | 72 69 6e 67 2e 0d 09 09 |e new st|ring....|
|00002170| 09 2f 2f 20 49 66 20 65 | 69 74 68 65 72 20 70 61 |.// If e|ither pa|
|00002180| 72 61 6d 65 74 65 72 20 | 69 73 20 6f 75 74 20 6f |rameter |is out o|
|00002190| 66 20 72 61 6e 67 65 2c | 20 6f 6e 6c 79 20 74 68 |f range,| only th|
|000021a0| 65 20 76 61 6c 69 64 20 | 70 61 72 74 20 69 73 20 |e valid |part is |
|000021b0| 72 65 74 75 72 6e 65 64 | 2e 0d 09 09 09 2f 2f 20 |returned|.....// |
|000021c0| 49 66 20 22 66 72 6f 6d | 22 20 3e 20 22 74 6f 22 |If "from|" > "to"|
|000021d0| 2c 20 61 6e 20 65 6d 70 | 74 79 20 4e 53 74 72 69 |, an emp|ty NStri|
|000021e0| 6e 67 20 69 73 20 72 65 | 74 75 72 6e 65 64 2e 0d |ng is re|turned..|
|000021f0| 09 09 09 0d 09 09 69 6e | 6c 69 6e 65 20 4e 53 74 |......in|line NSt|
|00002200| 72 69 6e 67 20 66 72 6f | 6d 20 28 75 6e 73 69 67 |ring fro|m (unsig|
|00002210| 6e 65 64 20 6c 6f 6e 67 | 20 69 6e 74 20 66 72 6f |ned long| int fro|
|00002220| 6d 29 20 63 6f 6e 73 74 | 3b 09 09 09 09 09 09 2f |m) const|;....../|
|00002230| 2f 09 09 74 20 3d 20 73 | 2e 66 72 6f 6d 28 33 29 |/..t = s|.from(3)|
|00002240| 3b 0d 09 09 09 2f 2f 20 | 72 65 74 75 72 6e 20 74 |;....// |return t|
|00002250| 68 65 20 73 75 62 73 74 | 72 69 6e 67 20 72 61 6e |he subst|ring ran|
|00002260| 67 69 6e 67 20 66 72 6f | 6d 20 63 68 61 72 61 63 |ging fro|m charac|
|00002270| 74 65 72 20 23 20 22 66 | 72 6f 6d 22 20 74 6f 0d |ter # "f|rom" to.|
|00002280| 09 09 09 2f 2f 20 09 74 | 68 65 20 65 6e 64 20 6f |...// .t|he end o|
|00002290| 66 20 74 68 65 20 6f 72 | 69 67 69 6e 61 6c 20 4e |f the or|iginal N|
|000022a0| 53 74 72 69 6e 67 2e 0d | 09 09 09 2f 2f 20 54 68 |String..|...// Th|
|000022b0| 69 73 20 66 75 6e 63 74 | 69 6f 6e 20 69 73 20 65 |is funct|ion is e|
|000022c0| 71 75 69 76 61 6c 65 6e | 74 20 74 6f 20 22 73 2e |quivalen|t to "s.|
|000022d0| 66 72 6f 6d 74 6f 28 66 | 72 6f 6d 2c 20 73 2e 6c |fromto(f|rom, s.l|
|000022e0| 65 6e 67 74 68 28 29 29 | 22 0d 09 09 09 2f 2f 20 |ength())|"....// |
|000022f0| 54 68 65 20 63 6f 6e 73 | 69 64 65 72 61 74 69 6f |The cons|ideratio|
|00002300| 6e 73 20 73 74 61 74 65 | 64 20 75 6e 64 65 72 20 |ns state|d under |
|00002310| 22 66 72 6f 6d 74 6f 22 | 20 61 70 70 6c 79 2e 0d |"fromto"| apply..|
|00002320| 09 09 09 0d 09 09 69 6e | 6c 69 6e 65 20 4e 53 74 |......in|line NSt|
|00002330| 72 69 6e 67 20 74 6f 20 | 28 75 6e 73 69 67 6e 65 |ring to |(unsigne|
|00002340| 64 20 6c 6f 6e 67 20 69 | 6e 74 20 74 6f 29 20 63 |d long i|nt to) c|
|00002350| 6f 6e 73 74 3b 09 09 09 | 09 09 09 09 09 09 2f 2f |onst;...|......//|
|00002360| 09 09 74 20 3d 20 73 2e | 74 6f 28 35 29 3b 0d 09 |..t = s.|to(5);..|
|00002370| 09 09 2f 2f 20 72 65 74 | 75 72 6e 20 74 68 65 20 |..// ret|urn the |
|00002380| 73 75 62 73 74 72 69 6e | 67 20 72 61 6e 67 69 6e |substrin|g rangin|
|00002390| 67 20 66 72 6f 6d 20 74 | 68 65 20 62 65 67 69 6e |g from t|he begin|
|000023a0| 6e 69 6e 67 20 6f 66 20 | 74 68 65 0d 09 09 09 2f |ning of |the..../|
|000023b0| 2f 20 09 6f 72 69 67 69 | 6e 61 6c 20 4e 53 74 72 |/ .origi|nal NStr|
|000023c0| 69 6e 67 20 74 6f 20 63 | 68 61 72 61 63 74 65 72 |ing to c|haracter|
|000023d0| 20 23 20 22 74 6f 22 2e | 0d 09 09 09 2f 2f 20 54 | # "to".|....// T|
|000023e0| 68 69 73 20 66 75 6e 63 | 74 69 6f 6e 20 69 73 20 |his func|tion is |
|000023f0| 65 71 75 69 76 61 6c 65 | 6e 74 20 74 6f 20 22 73 |equivale|nt to "s|
|00002400| 2e 66 72 6f 6d 74 6f 28 | 30 2c 20 74 6f 29 22 0d |.fromto(|0, to)".|
|00002410| 09 09 09 2f 2f 20 54 68 | 65 20 63 6f 6e 73 69 64 |...// Th|e consid|
|00002420| 65 72 61 74 69 6f 6e 73 | 20 73 74 61 74 65 64 20 |erations| stated |
|00002430| 75 6e 64 65 72 20 22 66 | 72 6f 6d 74 6f 22 20 61 |under "f|romto" a|
|00002440| 70 70 6c 79 2e 0d 0d 09 | 09 2f 2a 2d 2d 2d 2d 2d |pply....|./*-----|
|00002450| 2d 2d 2d 20 43 75 74 74 | 69 6e 67 20 70 61 72 74 |--- Cutt|ing part|
|00002460| 73 20 6f 75 74 20 6f 66 | 20 61 6e 20 4e 53 74 72 |s out of| an NStr|
|00002470| 69 6e 67 20 2d 2d 2d 2d | 2d 2d 2d 2d 2a 2f 0d 0d |ing ----|----*/..|
|00002480| 09 09 4e 53 74 72 69 6e | 67 26 20 63 75 74 28 75 |..NStrin|g& cut(u|
|00002490| 6e 73 69 67 6e 65 64 20 | 6c 6f 6e 67 20 69 6e 74 |nsigned |long int|
|000024a0| 20 61 74 2c 20 75 6e 73 | 69 67 6e 65 64 20 6c 6f | at, uns|igned lo|
|000024b0| 6e 67 20 69 6e 74 20 6e | 29 3b 09 09 09 09 09 2f |ng int n|);...../|
|000024c0| 2f 09 09 73 2e 63 75 74 | 28 33 2c 32 29 3b 0d 09 |/..s.cut|(3,2);..|
|000024d0| 09 09 2f 2f 20 72 65 6d | 6f 76 65 20 74 68 65 20 |..// rem|ove the |
|000024e0| 73 75 62 73 74 72 69 6e | 67 20 6f 66 20 6c 65 6e |substrin|g of len|
|000024f0| 67 74 68 20 22 6e 22 20 | 73 74 61 72 74 69 6e 67 |gth "n" |starting|
|00002500| 20 61 74 20 6c 65 74 74 | 65 72 20 23 20 22 61 74 | at lett|er # "at|
|00002510| 22 2e 0d 09 09 09 2f 2f | 09 28 54 68 65 20 66 69 |".....//|.(The fi|
|00002520| 72 73 74 20 63 68 61 72 | 61 63 74 65 72 20 6f 66 |rst char|acter of|
|00002530| 20 74 68 65 20 73 74 72 | 69 6e 67 20 69 73 20 63 | the str|ing is c|
|00002540| 68 61 72 61 63 74 65 72 | 20 23 20 31 2e 29 0d 09 |haracter| # 1.)..|
|00002550| 09 09 2f 2f 20 49 66 20 | 65 69 74 68 65 72 20 70 |..// If |either p|
|00002560| 61 72 61 6d 65 74 65 72 | 20 69 73 20 6f 75 74 20 |arameter| is out |
|00002570| 6f 66 20 72 61 6e 67 65 | 2c 20 6f 6e 6c 79 20 74 |of range|, only t|
|00002580| 68 65 20 76 61 6c 69 64 | 20 70 61 72 74 20 69 73 |he valid| part is|
|00002590| 20 63 75 74 2e 0d 09 09 | 09 2f 2f 20 49 66 20 6e | cut....|.// If n|
|000025a0| 3d 3d 30 2c 20 6e 6f 20 | 63 68 61 6e 67 65 20 69 |==0, no |change i|
|000025b0| 73 20 64 6f 6e 65 20 74 | 6f 20 74 68 65 20 4e 53 |s done t|o the NS|
|000025c0| 74 72 69 6e 67 2e 0d 09 | 09 09 2f 2f 20 54 68 65 |tring...|..// The|
|000025d0| 20 66 75 6e 63 74 69 6f | 6e 20 72 65 74 75 72 6e | functio|n return|
|000025e0| 73 20 61 20 72 65 66 65 | 72 65 6e 63 65 20 74 6f |s a refe|rence to|
|000025f0| 20 74 68 65 20 6d 6f 64 | 69 66 69 65 64 20 4e 53 | the mod|ified NS|
|00002600| 74 72 69 6e 67 3b 20 74 | 68 65 0d 09 09 09 2f 2f |tring; t|he....//|
|00002610| 09 09 63 75 74 20 70 61 | 72 74 20 69 73 20 6c 6f |..cut pa|rt is lo|
|00002620| 73 74 2e 0d 0d 09 09 2f | 2a 2d 2d 2d 2d 2d 2d 2d |st...../|*-------|
|00002630| 2d 20 49 74 65 72 61 74 | 6f 72 20 2d 2d 2d 2d 2d |- Iterat|or -----|
|00002640| 2d 2d 2d 2a 2f 0d 0d 09 | 09 65 6e 75 6d 20 64 69 |---*/...|.enum di|
|00002650| 72 65 63 74 69 6f 6e 5f | 74 20 7b 46 4f 52 57 41 |rection_|t {FORWA|
|00002660| 52 44 2c 20 42 41 43 4b | 57 41 52 44 7d 3b 0d 0d |RD, BACK|WARD};..|
|00002670| 09 09 4e 53 74 72 69 6e | 67 26 20 74 68 72 6f 75 |..NStrin|g& throu|
|00002680| 67 68 28 69 6e 74 20 28 | 2a 61 63 74 69 6f 6e 29 |gh(int (|*action)|
|00002690| 28 63 6f 6e 73 74 20 63 | 68 61 72 2c 20 63 6f 6e |(const c|har, con|
|000026a0| 73 74 20 75 6e 73 69 67 | 6e 65 64 20 6c 6f 6e 67 |st unsig|ned long|
|000026b0| 20 69 6e 74 2c 20 4e 53 | 74 72 69 6e 67 26 29 2c | int, NS|tring&),|
|000026c0| 20 64 69 72 65 63 74 69 | 6f 6e 5f 74 20 64 69 72 | directi|on_t dir|
|000026d0| 20 3d 20 46 4f 52 57 41 | 52 44 29 3b 0d 09 09 09 | = FORWA|RD);....|
|000026e0| 2f 2f 09 74 72 61 76 65 | 72 73 65 20 74 68 65 20 |//.trave|rse the |
|000026f0| 4e 53 74 72 69 6e 67 20 | 69 6e 20 74 68 65 20 73 |NString |in the s|
|00002700| 70 65 63 69 66 69 65 64 | 20 64 69 72 65 63 74 6f |pecified| directo|
|00002710| 6e 2c 20 63 61 6c 6c 69 | 6e 67 20 61 74 20 65 61 |n, calli|ng at ea|
|00002720| 63 68 20 73 74 65 70 20 | 74 68 65 20 67 69 76 65 |ch step |the give|
|00002730| 6e 20 66 75 6e 63 74 69 | 6f 6e 2e 0d 09 09 09 2f |n functi|on...../|
|00002740| 2f 20 54 68 65 20 22 61 | 63 74 69 6f 6e 22 20 66 |/ The "a|ction" f|
|00002750| 75 6e 63 74 69 6f 6e 20 | 72 65 63 65 69 76 65 73 |unction |receives|
|00002760| 20 61 73 20 70 61 72 61 | 6d 65 74 65 72 73 20 74 | as para|meters t|
|00002770| 68 65 20 63 75 72 72 65 | 6e 74 20 63 68 61 72 61 |he curre|nt chara|
|00002780| 63 74 65 72 2c 20 69 74 | 73 20 70 6f 73 69 74 69 |cter, it|s positi|
|00002790| 6f 6e 20 69 6e 0d 09 09 | 09 2f 2f 09 09 74 68 65 |on in...|.//..the|
|000027a0| 20 4e 53 74 72 69 6e 67 | 20 28 73 74 61 72 74 69 | NString| (starti|
|000027b0| 6e 67 20 66 72 6f 6d 20 | 31 29 20 61 6e 64 20 61 |ng from |1) and a|
|000027c0| 20 72 65 66 65 72 65 6e | 63 65 20 74 6f 20 74 68 | referen|ce to th|
|000027d0| 65 20 4e 53 74 72 69 6e | 67 20 62 65 69 6e 67 20 |e NStrin|g being |
|000027e0| 74 72 61 76 65 72 73 65 | 64 2e 0d 09 09 09 2f 2f |traverse|d.....//|
|000027f0| 09 49 66 20 74 68 65 20 | 4e 53 74 72 69 6e 67 20 |.If the |NString |
|00002800| 69 73 20 65 6d 70 74 79 | 2c 20 74 68 65 20 69 74 |is empty|, the it|
|00002810| 65 72 61 74 6f 72 20 64 | 6f 65 73 20 6e 6f 74 68 |erator d|oes noth|
|00002820| 69 6e 67 2e 0d 09 09 09 | 2f 2f 09 49 66 20 74 68 |ing.....|//.If th|
|00002830| 65 20 4e 53 74 72 69 6e | 67 20 69 73 20 61 6c 74 |e NStrin|g is alt|
|00002840| 65 72 65 64 20 64 75 72 | 69 6e 67 20 69 74 65 72 |ered dur|ing iter|
|00002850| 61 74 69 6f 6e 2c 20 74 | 68 65 73 65 20 6d 6f 64 |ation, t|hese mod|
|00002860| 69 66 69 63 61 74 69 6f | 6e 73 20 77 69 6c 6c 20 |ificatio|ns will |
|00002870| 4e 4f 54 20 61 66 66 65 | 63 74 20 74 68 65 20 69 |NOT affe|ct the i|
|00002880| 74 65 72 61 74 69 6f 6e | 0d 09 09 09 2f 2f 09 09 |teration|....//..|
|00002890| 70 72 6f 63 65 73 73 2c | 20 61 73 20 74 68 65 20 |process,| as the |
|000028a0| 73 74 72 69 6e 67 20 62 | 65 69 6e 67 20 74 72 61 |string b|eing tra|
|000028b0| 76 65 72 73 65 64 20 69 | 73 20 61 63 74 75 61 6c |versed i|s actual|
|000028c0| 6c 79 20 61 20 63 6f 70 | 79 20 6f 66 20 74 68 65 |ly a cop|y of the|
|000028d0| 20 6f 72 69 67 69 6e 61 | 6c 20 73 74 72 69 6e 67 | origina|l string|
|000028e0| 2e 0d 09 09 09 2f 2f 09 | 54 68 65 20 22 61 63 74 |.....//.|The "act|
|000028f0| 69 6f 6e 22 20 6d 61 79 | 20 69 6e 74 65 72 72 75 |ion" may| interru|
|00002900| 70 74 20 74 68 65 20 69 | 74 65 72 61 74 69 6f 6e |pt the i|teration|
|00002910| 20 70 72 6f 63 65 73 73 | 20 62 79 20 72 65 74 75 | process| by retu|
|00002920| 72 6e 69 6e 67 20 61 20 | 6e 6f 6e 2d 7a 65 72 6f |rning a |non-zero|
|00002930| 20 76 61 6c 75 65 2e 0d | 09 09 09 2f 2f 09 09 5a | value..|...//..Z|
|00002940| 65 72 6f 20 6d 75 73 74 | 20 62 65 20 72 65 74 75 |ero must| be retu|
|00002950| 72 6e 65 64 20 66 6f 72 | 20 74 68 65 20 69 74 65 |rned for| the ite|
|00002960| 72 61 74 69 6f 6e 20 74 | 6f 20 70 72 6f 63 65 65 |ration t|o procee|
|00002970| 64 20 75 6e 74 69 6c 20 | 74 68 65 20 65 6e 64 20 |d until |the end |
|00002980| 6f 66 20 74 68 65 20 73 | 74 72 69 6e 67 20 69 73 |of the s|tring is|
|00002990| 20 72 65 61 63 68 65 64 | 2e 0d 09 09 09 2f 2f 09 | reached|.....//.|
|000029a0| 54 68 65 20 69 74 65 72 | 61 74 6f 72 20 72 65 74 |The iter|ator ret|
|000029b0| 75 72 6e 73 20 61 20 72 | 65 66 65 72 65 6e 63 65 |urns a r|eference|
|000029c0| 20 74 6f 20 74 68 65 20 | 4e 53 74 72 69 6e 67 20 | to the |NString |
|000029d0| 62 65 69 6e 67 20 74 72 | 61 76 65 72 73 65 64 2e |being tr|aversed.|
|000029e0| 0d 09 09 09 0d 09 09 09 | 2f 2f 09 45 78 61 6d 70 |........|//.Examp|
|000029f0| 6c 65 3a 20 22 73 2e 74 | 68 72 6f 75 67 68 28 26 |le: "s.t|hrough(&|
|00002a00| 70 72 69 6e 74 2c 20 4e | 53 74 72 69 6e 67 3a 3a |print, N|String::|
|00002a10| 42 41 43 4b 57 41 52 44 | 29 22 20 77 68 65 72 65 |BACKWARD|)" where|
|00002a20| 20 70 72 69 6e 74 28 29 | 20 68 61 73 20 62 65 65 | print()| has bee|
|00002a30| 6e 20 70 72 65 76 69 6f | 75 73 6c 79 20 64 65 66 |n previo|usly def|
|00002a40| 69 6e 65 64 3b 0d 0d 09 | 09 2f 2a 2d 2d 2d 2d 2d |ined;...|./*-----|
|00002a50| 2d 2d 2d 20 54 72 61 6e | 73 66 6f 72 6d 69 6e 67 |--- Tran|sforming|
|00002a60| 20 4e 53 74 72 69 6e 67 | 73 20 2d 2d 2d 2d 2d 2d | NString|s ------|
|00002a70| 2d 2d 2a 2f 0d 0d 09 09 | 4e 53 74 72 69 6e 67 20 |--*/....|NString |
|00002a80| 75 70 63 61 73 65 20 28 | 76 6f 69 64 29 20 63 6f |upcase (|void) co|
|00002a90| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 09 09 09 09 |nst;....|........|
|00002aa0| 09 09 2f 2f 09 09 74 20 | 3d 20 73 2e 75 70 63 61 |..//..t |= s.upca|
|00002ab0| 73 65 28 29 3b 0d 09 09 | 09 2f 2f 09 67 65 74 20 |se();...|.//.get |
|00002ac0| 61 20 6e 65 77 20 4e 53 | 74 72 69 6e 67 20 63 6f |a new NS|tring co|
|00002ad0| 6e 73 69 73 74 69 6e 67 | 20 6f 66 20 74 68 65 20 |nsisting| of the |
|00002ae0| 6f 72 69 67 69 6e 61 6c | 20 6f 6e 65 20 63 6f 6e |original| one con|
|00002af0| 76 65 72 74 65 64 20 74 | 6f 20 75 70 70 65 72 20 |verted t|o upper |
|00002b00| 63 61 73 65 2e 0d 0d 09 | 09 4e 53 74 72 69 6e 67 |case....|.NString|
|00002b10| 20 6c 6f 77 63 61 73 65 | 20 28 76 6f 69 64 29 20 | lowcase| (void) |
|00002b20| 63 6f 6e 73 74 3b 09 09 | 09 09 09 09 09 09 09 09 |const;..|........|
|00002b30| 09 09 09 09 2f 2f 09 09 | 74 20 3d 20 73 2e 6c 6f |....//..|t = s.lo|
|00002b40| 77 63 61 73 65 28 29 3b | 0d 09 09 09 2f 2f 09 67 |wcase();|....//.g|
|00002b50| 65 74 20 61 20 6e 65 77 | 20 4e 53 74 72 69 6e 67 |et a new| NString|
|00002b60| 20 63 6f 6e 73 69 73 74 | 69 6e 67 20 6f 66 20 74 | consist|ing of t|
|00002b70| 68 65 20 6f 72 69 67 69 | 6e 61 6c 20 6f 6e 65 20 |he origi|nal one |
|00002b80| 63 6f 6e 76 65 72 74 65 | 64 20 74 6f 20 6c 6f 77 |converte|d to low|
|00002b90| 65 72 20 63 61 73 65 2e | 0d 0d 09 09 4e 53 74 72 |er case.|....NStr|
|00002ba0| 69 6e 67 26 20 74 6f 75 | 70 63 61 73 65 20 28 76 |ing& tou|pcase (v|
|00002bb0| 6f 69 64 29 3b 09 09 09 | 09 09 09 09 09 09 09 09 |oid);...|........|
|00002bc0| 09 09 09 09 2f 2f 09 09 | 73 2e 74 6f 75 70 63 61 |....//..|s.toupca|
|00002bd0| 73 65 28 29 3b 0d 09 09 | 09 2f 2f 20 63 6f 6e 76 |se();...|.// conv|
|00002be0| 65 72 74 20 74 68 69 73 | 20 4e 53 74 72 69 6e 67 |ert this| NString|
|00002bf0| 20 74 6f 20 75 70 70 65 | 72 63 61 73 65 2e 0d 09 | to uppe|rcase...|
|00002c00| 09 09 0d 09 09 4e 53 74 | 72 69 6e 67 26 20 74 6f |.....NSt|ring& to|
|00002c10| 6c 6f 77 63 61 73 65 20 | 28 76 6f 69 64 29 3b 09 |lowcase |(void);.|
|00002c20| 09 09 09 09 09 09 09 09 | 09 09 09 09 09 09 2f 2f |........|......//|
|00002c30| 09 09 73 2e 74 6f 6c 6f | 77 63 61 73 65 28 29 3b |..s.tolo|wcase();|
|00002c40| 0d 09 09 09 2f 2f 20 63 | 6f 6e 76 65 72 74 20 74 |....// c|onvert t|
|00002c50| 68 69 73 20 4e 53 74 72 | 69 6e 67 20 74 6f 20 6c |his NStr|ing to l|
|00002c60| 6f 77 65 72 63 61 73 65 | 2e 0d 0d 09 09 4e 53 74 |owercase|.....NSt|
|00002c70| 72 69 6e 67 26 20 63 6c | 65 61 72 20 28 76 6f 69 |ring& cl|ear (voi|
|00002c80| 64 29 3b 09 09 09 09 09 | 09 09 09 09 09 09 09 09 |d);.....|........|
|00002c90| 09 09 09 2f 2f 09 09 73 | 2e 63 6c 65 61 72 28 29 |...//..s|.clear()|
|00002ca0| 3b 0d 09 09 09 2f 2f 20 | 63 6c 65 61 72 20 74 68 |;....// |clear th|
|00002cb0| 69 73 20 4e 53 74 72 69 | 6e 67 2e 0d 0d 09 09 2f |is NStri|ng...../|
|00002cc0| 2a 2d 2d 2d 2d 2d 2d 2d | 2d 20 47 65 74 74 69 6e |*-------|- Gettin|
|00002cd0| 67 20 63 6f 6e 74 65 78 | 74 20 70 6f 73 69 74 69 |g contex|t positi|
|00002ce0| 6f 6e 20 69 6e 20 61 6e | 20 4e 53 74 72 69 6e 67 |on in an| NString|
|00002cf0| 20 2d 2d 2d 2d 2d 2d 2d | 2d 2a 2f 0d 0d 09 09 75 | -------|-*/....u|
|00002d00| 6e 73 69 67 6e 65 64 20 | 6c 6f 6e 67 20 69 6e 74 |nsigned |long int|
|00002d10| 20 6c 65 66 74 70 6f 73 | 20 28 63 6f 6e 73 74 20 | leftpos| (const |
|00002d20| 63 68 61 72 20 2a 73 29 | 20 63 6f 6e 73 74 3b 09 |char *s)| const;.|
|00002d30| 09 09 09 09 09 09 09 2f | 2f 09 09 6b 20 3d 20 73 |......./|/..k = s|
|00002d40| 2e 6c 65 66 74 70 6f 73 | 28 22 6c 6f 6f 70 22 29 |.leftpos|("loop")|
|00002d50| 3b 0d 0d 09 09 75 6e 73 | 69 67 6e 65 64 20 6c 6f |;....uns|igned lo|
|00002d60| 6e 67 20 69 6e 74 20 6c | 65 66 74 70 6f 73 20 28 |ng int l|eftpos (|
|00002d70| 63 6f 6e 73 74 20 63 68 | 61 72 20 63 29 20 63 6f |const ch|ar c) co|
|00002d80| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 09 2f 2f 09 |nst;....|.....//.|
|00002d90| 09 6b 20 3d 20 73 2e 6c | 65 66 74 70 6f 73 28 27 |.k = s.l|eftpos('|
|00002da0| 4c 27 29 3b 0d 0d 09 09 | 69 6e 6c 69 6e 65 20 75 |L');....|inline u|
|00002db0| 6e 73 69 67 6e 65 64 20 | 6c 6f 6e 67 20 69 6e 74 |nsigned |long int|
|00002dc0| 20 6c 65 66 74 70 6f 73 | 20 28 63 6f 6e 73 74 20 | leftpos| (const |
|00002dd0| 4e 53 74 72 69 6e 67 26 | 20 73 29 20 63 6f 6e 73 |NString&| s) cons|
|00002de0| 74 3b 09 09 09 09 09 2f | 2f 09 09 6b 20 3d 20 73 |t;...../|/..k = s|
|00002df0| 2e 6c 65 66 74 70 6f 73 | 28 74 29 3b 0d 0d 09 09 |.leftpos|(t);....|
|00002e00| 75 6e 73 69 67 6e 65 64 | 20 6c 6f 6e 67 20 69 6e |unsigned| long in|
|00002e10| 74 20 6c 65 66 74 70 6f | 73 20 28 63 6f 6e 73 74 |t leftpo|s (const|
|00002e20| 20 41 6c 70 68 61 62 65 | 74 26 20 61 29 20 63 6f | Alphabe|t& a) co|
|00002e30| 6e 73 74 3b 09 09 09 09 | 09 09 09 2f 2f 09 09 6b |nst;....|...//..k|
|00002e40| 20 3d 20 73 2e 6c 65 66 | 74 70 6f 73 28 61 6c 70 | = s.lef|tpos(alp|
|00002e50| 68 61 29 3b 0d 09 09 09 | 2f 2f 09 72 65 74 75 72 |ha);....|//.retur|
|00002e60| 6e 20 74 68 65 20 70 6f | 73 69 74 69 6f 6e 20 6f |n the po|sition o|
|00002e70| 66 20 74 68 65 20 6c 65 | 66 74 6d 6f 73 74 20 6f |f the le|ftmost o|
|00002e80| 63 63 75 72 72 65 6e 63 | 65 20 6f 66 0d 09 09 09 |ccurrenc|e of....|
|00002e90| 2f 2f 09 09 74 68 65 20 | 63 6f 6e 74 65 78 74 20 |//..the |context |
|00002ea0| 69 6e 20 74 68 65 20 4e | 53 74 72 69 6e 67 2e 0d |in the N|String..|
|00002eb0| 09 09 09 2f 2f 09 54 68 | 65 20 66 69 72 73 74 20 |...//.Th|e first |
|00002ec0| 63 68 61 72 61 63 74 65 | 72 20 6f 66 20 74 68 65 |characte|r of the|
|00002ed0| 20 4e 53 74 72 69 6e 67 | 20 68 61 73 20 70 6f 73 | NString| has pos|
|00002ee0| 69 74 69 6f 6e 20 31 2e | 0d 09 09 09 2f 2f 09 49 |ition 1.|....//.I|
|00002ef0| 66 20 61 6e 20 6f 63 63 | 75 72 72 65 6e 63 65 20 |f an occ|urrence |
|00002f00| 63 61 6e 6e 6f 74 20 62 | 65 20 66 6f 75 6e 64 2c |cannot b|e found,|
|00002f10| 20 7a 65 72 6f 20 69 73 | 20 72 65 74 75 72 6e 65 | zero is| returne|
|00002f20| 64 2e 0d 09 09 09 2f 2f | 09 49 66 20 74 68 65 20 |d.....//|.If the |
|00002f30| 63 6f 6e 74 65 78 74 20 | 69 73 20 61 6e 20 65 6d |context |is an em|
|00002f40| 70 74 79 20 73 74 72 69 | 6e 67 2c 20 6c 65 66 74 |pty stri|ng, left|
|00002f50| 70 6f 73 28 29 20 72 65 | 74 75 72 6e 73 20 31 2c |pos() re|turns 1,|
|00002f60| 0d 09 09 09 2f 2f 09 09 | 61 73 20 61 6e 20 65 6d |....//..|as an em|
|00002f70| 70 74 79 20 73 74 72 69 | 6e 67 20 63 61 6e 20 62 |pty stri|ng can b|
|00002f80| 65 20 66 6f 75 6e 64 20 | 65 76 65 72 79 77 68 65 |e found |everywhe|
|00002f90| 72 65 2e 0d 0d 0d 09 09 | 75 6e 73 69 67 6e 65 64 |re......|unsigned|
|00002fa0| 20 6c 6f 6e 67 20 69 6e | 74 20 72 69 67 68 74 70 | long in|t rightp|
|00002fb0| 6f 73 20 28 63 6f 6e 73 | 74 20 63 68 61 72 20 2a |os (cons|t char *|
|00002fc0| 73 29 20 63 6f 6e 73 74 | 3b 09 09 09 09 09 09 09 |s) const|;.......|
|00002fd0| 2f 2f 09 09 6b 20 3d 20 | 73 2e 72 69 67 68 74 70 |//..k = |s.rightp|
|00002fe0| 6f 73 28 22 65 6e 64 22 | 29 3b 0d 0d 09 09 75 6e |os("end"|);....un|
|00002ff0| 73 69 67 6e 65 64 20 6c | 6f 6e 67 20 69 6e 74 20 |signed l|ong int |
|00003000| 72 69 67 68 74 70 6f 73 | 20 28 63 6f 6e 73 74 20 |rightpos| (const |
|00003010| 63 68 61 72 20 63 29 20 | 63 6f 6e 73 74 3b 09 09 |char c) |const;..|
|00003020| 09 09 09 09 09 09 2f 2f | 09 09 6b 20 3d 20 73 2e |......//|..k = s.|
|00003030| 72 69 67 68 74 70 6f 73 | 28 27 52 27 29 3b 0d 0d |rightpos|('R');..|
|00003040| 09 09 69 6e 6c 69 6e 65 | 20 75 6e 73 69 67 6e 65 |..inline| unsigne|
|00003050| 64 20 6c 6f 6e 67 20 69 | 6e 74 20 72 69 67 68 74 |d long i|nt right|
|00003060| 70 6f 73 20 28 63 6f 6e | 73 74 20 4e 53 74 72 69 |pos (con|st NStri|
|00003070| 6e 67 26 20 73 29 20 63 | 6f 6e 73 74 3b 09 09 09 |ng& s) c|onst;...|
|00003080| 09 2f 2f 09 09 6b 20 3d | 20 73 2e 72 69 67 68 74 |.//..k =| s.right|
|00003090| 70 6f 73 28 74 29 3b 0d | 0d 09 09 75 6e 73 69 67 |pos(t);.|...unsig|
|000030a0| 6e 65 64 20 6c 6f 6e 67 | 20 69 6e 74 20 72 69 67 |ned long| int rig|
|000030b0| 68 74 70 6f 73 20 28 63 | 6f 6e 73 74 20 41 6c 70 |htpos (c|onst Alp|
|000030c0| 68 61 62 65 74 26 20 61 | 29 20 63 6f 6e 73 74 3b |habet& a|) const;|
|000030d0| 09 09 09 09 09 09 2f 2f | 09 09 6b 20 3d 20 73 2e |......//|..k = s.|
|000030e0| 72 69 67 68 74 70 6f 73 | 28 61 6c 70 68 61 29 3b |rightpos|(alpha);|
|000030f0| 0d 09 09 09 2f 2f 09 72 | 65 74 75 72 6e 20 74 68 |....//.r|eturn th|
|00003100| 65 20 70 6f 73 69 74 69 | 6f 6e 20 6f 66 20 74 68 |e positi|on of th|
|00003110| 65 20 72 69 67 68 74 6d | 6f 73 74 20 6f 63 63 75 |e rightm|ost occu|
|00003120| 72 72 65 6e 63 65 20 6f | 66 0d 09 09 09 2f 2f 09 |rrence o|f....//.|
|00003130| 09 74 68 65 20 63 6f 6e | 74 65 78 74 20 69 6e 20 |.the con|text in |
|00003140| 74 68 65 20 4e 53 74 72 | 69 6e 67 2e 0d 09 09 09 |the NStr|ing.....|
|00003150| 2f 2f 09 54 68 65 20 66 | 69 72 73 74 20 63 68 61 |//.The f|irst cha|
|00003160| 72 61 63 74 65 72 20 6f | 66 20 74 68 65 20 4e 53 |racter o|f the NS|
|00003170| 74 72 69 6e 67 20 68 61 | 73 20 70 6f 73 69 74 69 |tring ha|s positi|
|00003180| 6f 6e 20 31 2e 0d 09 09 | 09 2f 2f 09 49 66 20 61 |on 1....|.//.If a|
|00003190| 6e 20 6f 63 63 75 72 72 | 65 6e 63 65 20 63 61 6e |n occurr|ence can|
|000031a0| 6e 6f 74 20 62 65 20 66 | 6f 75 6e 64 2c 20 7a 65 |not be f|ound, ze|
|000031b0| 72 6f 20 69 73 20 72 65 | 74 75 72 6e 65 64 2e 0d |ro is re|turned..|
|000031c0| 09 09 09 2f 2f 09 49 66 | 20 74 68 65 20 63 6f 6e |...//.If| the con|
|000031d0| 74 65 78 74 20 69 73 20 | 61 6e 20 65 6d 70 74 79 |text is |an empty|
|000031e0| 20 73 74 72 69 6e 67 2c | 20 72 69 67 68 74 70 6f | string,| rightpo|
|000031f0| 73 28 29 20 72 65 74 75 | 72 6e 73 20 22 73 2e 6c |s() retu|rns "s.l|
|00003200| 65 6e 67 74 68 28 29 2b | 31 22 2c 0d 09 09 09 2f |ength()+|1",..../|
|00003210| 2f 09 09 61 73 20 61 6e | 20 65 6d 70 74 79 20 73 |/..as an| empty s|
|00003220| 74 72 69 6e 67 20 63 61 | 6e 20 62 65 20 66 6f 75 |tring ca|n be fou|
|00003230| 6e 64 20 65 76 65 72 79 | 77 68 65 72 65 2e 0d 09 |nd every|where...|
|00003240| 09 09 2f 2f 20 49 6e 20 | 74 68 65 20 63 61 73 65 |..// In |the case|
|00003250| 20 6f 66 20 61 6e 20 61 | 6c 70 68 61 62 65 74 2d | of an a|lphabet-|
|00003260| 63 6f 6e 74 65 78 74 2c | 20 74 68 65 20 72 65 73 |context,| the res|
|00003270| 75 6c 74 20 69 73 20 74 | 68 65 20 70 6f 73 69 74 |ult is t|he posit|
|00003280| 69 6f 6e 0d 09 09 09 2f | 2f 09 09 6f 66 20 74 68 |ion..../|/..of th|
|00003290| 65 20 66 69 72 73 74 20 | 6c 65 74 74 65 72 20 74 |e first |letter t|
|000032a0| 68 61 74 20 69 73 20 65 | 6e 63 6f 75 6e 74 65 72 |hat is e|ncounter|
|000032b0| 65 64 20 77 68 65 6e 20 | 73 63 61 6e 6e 69 6e 67 |ed when |scanning|
|000032c0| 20 74 68 65 20 4e 53 74 | 72 69 6e 67 0d 09 09 09 | the NSt|ring....|
|000032d0| 2f 2f 09 09 62 61 63 6b | 77 61 72 64 73 20 41 4e |//..back|wards AN|
|000032e0| 44 20 74 68 61 74 20 69 | 73 20 63 6f 6e 74 61 69 |D that i|s contai|
|000032f0| 6e 65 64 20 69 6e 20 74 | 68 65 20 61 6c 70 68 61 |ned in t|he alpha|
|00003300| 62 65 74 2e 20 46 6f 72 | 20 65 78 61 6d 70 6c 65 |bet. For| example|
|00003310| 2c 0d 09 09 09 2f 2f 09 | 09 69 66 20 22 61 6c 70 |,....//.|.if "alp|
|00003320| 68 61 22 20 63 6f 6e 74 | 61 69 6e 73 20 74 68 65 |ha" cont|ains the|
|00003330| 20 6c 65 74 74 65 72 73 | 20 27 61 27 2c 20 27 6d | letters| 'a', 'm|
|00003340| 27 20 61 6e 64 20 27 72 | 27 2c 20 61 6e 64 20 74 |' and 'r|', and t|
|00003350| 68 65 20 4e 53 74 72 69 | 6e 67 20 22 73 22 0d 09 |he NStri|ng "s"..|
|00003360| 09 09 2f 2f 09 09 63 6f | 6e 74 61 69 6e 73 20 74 |..//..co|ntains t|
|00003370| 68 65 20 73 74 72 69 6e | 67 20 22 53 75 70 65 72 |he strin|g "Super|
|00003380| 6d 61 6e 22 2c 20 74 68 | 65 20 63 61 6c 6c 20 22 |man", th|e call "|
|00003390| 73 2e 72 69 67 68 74 70 | 6f 73 28 61 6c 70 68 61 |s.rightp|os(alpha|
|000033a0| 29 22 0d 09 09 09 2f 2f | 09 09 72 65 74 75 72 6e |)"....//|..return|
|000033b0| 73 20 74 68 65 20 76 61 | 6c 75 65 20 37 2c 20 69 |s the va|lue 7, i|
|000033c0| 2e 65 2e 20 74 68 65 20 | 70 6f 73 69 74 69 6f 6e |.e. the |position|
|000033d0| 20 6f 66 20 74 68 65 20 | 6c 65 74 74 65 72 20 27 | of the |letter '|
|000033e0| 61 27 2e 0d 0d 09 09 2f | 2a 2d 2d 2d 2d 2d 2d 2d |a'...../|*-------|
|000033f0| 2d 20 43 6f 70 79 69 6e | 67 20 63 6f 6e 74 65 78 |- Copyin|g contex|
|00003400| 74 2d 64 65 70 65 6e 64 | 61 6e 74 20 70 61 72 74 |t-depend|ant part|
|00003410| 73 20 6f 66 20 61 6e 20 | 4e 53 74 72 69 6e 67 20 |s of an |NString |
|00003420| 2d 2d 2d 2d 2d 2d 2d 2d | 2a 2f 0d 0d 09 09 4e 53 |--------|*/....NS|
|00003430| 74 72 69 6e 67 20 6c 65 | 66 74 6f 66 20 28 63 6f |tring le|ftof (co|
|00003440| 6e 73 74 20 63 68 61 72 | 20 2a 63 6f 6e 74 65 78 |nst char| *contex|
|00003450| 74 29 20 63 6f 6e 73 74 | 3b 09 09 09 09 09 09 09 |t) const|;.......|
|00003460| 09 09 09 2f 2f 09 09 74 | 20 3d 20 73 2e 6c 65 66 |...//..t| = s.lef|
|00003470| 74 6f 66 28 22 62 65 67 | 69 6e 22 29 3b 0d 0d 09 |tof("beg|in");...|
|00003480| 09 4e 53 74 72 69 6e 67 | 20 6c 65 66 74 6f 66 20 |.NString| leftof |
|00003490| 28 63 6f 6e 73 74 20 63 | 68 61 72 20 63 6f 6e 74 |(const c|har cont|
|000034a0| 65 78 74 29 20 63 6f 6e | 73 74 3b 09 09 09 09 09 |ext) con|st;.....|
|000034b0| 09 09 09 09 09 2f 2f 09 | 09 74 20 3d 20 73 2e 6c |.....//.|.t = s.l|
|000034c0| 65 66 74 6f 66 28 27 62 | 27 29 3b 0d 0d 09 09 4e |eftof('b|');....N|
|000034d0| 53 74 72 69 6e 67 20 6c | 65 66 74 6f 66 20 28 63 |String l|eftof (c|
|000034e0| 6f 6e 73 74 20 4e 53 74 | 72 69 6e 67 26 20 63 6f |onst NSt|ring& co|
|000034f0| 6e 74 65 78 74 29 20 63 | 6f 6e 73 74 3b 09 09 09 |ntext) c|onst;...|
|00003500| 09 09 09 09 09 2f 2f 09 | 09 74 20 3d 20 73 2e 6c |.....//.|.t = s.l|
|00003510| 65 66 74 6f 66 28 74 29 | 3b 0d 0d 09 09 4e 53 74 |eftof(t)|;....NSt|
|00003520| 72 69 6e 67 20 6c 65 66 | 74 6f 66 20 28 63 6f 6e |ring lef|tof (con|
|00003530| 73 74 20 41 6c 70 68 61 | 62 65 74 26 20 63 6f 6e |st Alpha|bet& con|
|00003540| 74 65 78 74 29 20 63 6f | 6e 73 74 3b 09 09 09 09 |text) co|nst;....|
|00003550| 09 09 09 09 2f 2f 09 09 | 74 20 3d 20 73 2e 6c 65 |....//..|t = s.le|
|00003560| 66 74 6f 66 28 61 6c 70 | 68 61 29 3b 0d 09 09 09 |ftof(alp|ha);....|
|00003570| 2f 2f 09 72 65 74 75 72 | 6e 20 74 68 65 20 69 6e |//.retur|n the in|
|00003580| 69 74 69 61 6c 20 70 61 | 72 74 20 6f 66 20 74 68 |itial pa|rt of th|
|00003590| 65 20 4e 53 74 72 69 6e | 67 20 6e 6f 74 20 63 6f |e NStrin|g not co|
|000035a0| 6e 74 61 69 6e 69 6e 67 | 0d 09 09 09 2f 2f 09 09 |ntaining|....//..|
|000035b0| 74 68 65 20 6c 65 66 74 | 6d 6f 73 74 20 63 6f 6e |the left|most con|
|000035c0| 74 65 78 74 20 6f 63 63 | 75 72 72 65 6e 63 65 2e |text occ|urrence.|
|000035d0| 0d 09 09 09 2f 2f 20 54 | 68 65 20 72 65 73 75 6c |....// T|he resul|
|000035e0| 74 20 6f 66 20 74 68 69 | 73 20 66 75 6e 63 74 69 |t of thi|s functi|
|000035f0| 6f 6e 20 77 69 6c 6c 20 | 62 65 3a 0d 09 09 09 2f |on will |be:..../|
|00003600| 2f 09 09 a5 20 63 6f 6e | 74 65 78 74 20 6f 63 63 |/... con|text occ|
|00003610| 75 72 72 65 6e 63 65 20 | 6e 6f 74 20 66 6f 75 6e |urrence |not foun|
|00003620| 64 3a 20 74 68 65 20 65 | 6e 74 69 72 65 20 4e 53 |d: the e|ntire NS|
|00003630| 74 72 69 6e 67 0d 09 09 | 09 2f 2f 09 09 a5 20 63 |tring...|.//... c|
|00003640| 6f 6e 74 65 78 74 20 6f | 63 63 75 72 72 65 6e 63 |ontext o|ccurrenc|
|00003650| 65 20 61 74 20 70 6f 73 | 69 74 69 6f 6e 20 31 3a |e at pos|ition 1:|
|00003660| 20 61 6e 20 65 6d 70 74 | 79 20 4e 53 74 72 69 6e | an empt|y NStrin|
|00003670| 67 0d 09 09 09 2f 2f 09 | 09 a5 20 63 6f 6e 74 65 |g....//.|.. conte|
|00003680| 78 74 20 6f 63 63 75 72 | 72 65 6e 63 65 20 6e 6f |xt occur|rence no|
|00003690| 74 20 73 74 61 72 74 69 | 6e 67 20 61 74 20 70 6f |t starti|ng at po|
|000036a0| 73 69 74 69 6f 6e 20 31 | 3a 20 22 74 6f 28 6c 65 |sition 1|: "to(le|
|000036b0| 66 74 70 6f 73 28 63 6f | 6e 74 65 78 74 29 2d 31 |ftpos(co|ntext)-1|
|000036c0| 29 22 0d 0d 0d 09 09 4e | 53 74 72 69 6e 67 20 61 |)".....N|String a|
|000036d0| 74 6c 65 66 74 20 28 63 | 6f 6e 73 74 20 63 68 61 |tleft (c|onst cha|
|000036e0| 72 20 2a 63 6f 6e 74 65 | 78 74 29 20 63 6f 6e 73 |r *conte|xt) cons|
|000036f0| 74 3b 09 09 09 09 09 09 | 09 09 09 09 2f 2f 09 09 |t;......|....//..|
|00003700| 74 20 3d 20 73 2e 61 74 | 6c 65 66 74 28 22 62 65 |t = s.at|left("be|
|00003710| 67 69 6e 22 29 3b 0d 0d | 09 09 4e 53 74 72 69 6e |gin");..|..NStrin|
|00003720| 67 20 61 74 6c 65 66 74 | 20 28 63 6f 6e 73 74 20 |g atleft| (const |
|00003730| 63 68 61 72 20 63 6f 6e | 74 65 78 74 29 20 63 6f |char con|text) co|
|00003740| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 09 09 2f 2f |nst;....|......//|
|00003750| 09 09 74 20 3d 20 73 2e | 61 74 6c 65 66 74 28 27 |..t = s.|atleft('|
|00003760| 62 27 29 3b 0d 0d 09 09 | 4e 53 74 72 69 6e 67 20 |b');....|NString |
|00003770| 61 74 6c 65 66 74 20 28 | 63 6f 6e 73 74 20 4e 53 |atleft (|const NS|
|00003780| 74 72 69 6e 67 26 20 63 | 6f 6e 74 65 78 74 29 20 |tring& c|ontext) |
|00003790| 63 6f 6e 73 74 3b 09 09 | 09 09 09 09 09 09 2f 2f |const;..|......//|
|000037a0| 09 09 74 20 3d 20 73 2e | 61 74 6c 65 66 74 28 74 |..t = s.|atleft(t|
|000037b0| 29 3b 0d 0d 09 09 4e 53 | 74 72 69 6e 67 20 61 74 |);....NS|tring at|
|000037c0| 6c 65 66 74 20 28 63 6f | 6e 73 74 20 41 6c 70 68 |left (co|nst Alph|
|000037d0| 61 62 65 74 26 20 63 6f | 6e 74 65 78 74 29 20 63 |abet& co|ntext) c|
|000037e0| 6f 6e 73 74 3b 09 09 09 | 09 09 09 09 09 2f 2f 09 |onst;...|.....//.|
|000037f0| 09 74 20 3d 20 73 2e 61 | 74 6c 65 66 74 28 61 6c |.t = s.a|tleft(al|
|00003800| 70 68 61 29 3b 0d 09 09 | 09 2f 2f 09 72 65 74 75 |pha);...|.//.retu|
|00003810| 72 6e 20 74 68 65 20 66 | 69 6e 61 6c 20 70 61 72 |rn the f|inal par|
|00003820| 74 20 6f 66 20 74 68 65 | 20 4e 53 74 72 69 6e 67 |t of the| NString|
|00003830| 20 73 74 61 72 74 69 6e | 67 20 61 74 20 74 68 65 | startin|g at the|
|00003840| 20 70 6f 73 69 74 69 6f | 6e 20 6f 66 0d 09 09 09 | positio|n of....|
|00003850| 2f 2f 09 09 74 68 65 20 | 6c 65 66 74 6d 6f 73 74 |//..the |leftmost|
|00003860| 20 63 6f 6e 74 65 78 74 | 20 6f 63 63 75 72 72 65 | context| occurre|
|00003870| 6e 63 65 2e 0d 09 09 09 | 2f 2f 20 54 68 65 20 72 |nce.....|// The r|
|00003880| 65 73 75 6c 74 20 6f 66 | 20 74 68 69 73 20 66 75 |esult of| this fu|
|00003890| 6e 63 74 69 6f 6e 20 77 | 69 6c 6c 20 62 65 3a 0d |nction w|ill be:.|
|000038a0| 09 09 09 2f 2f 09 09 a5 | 20 63 6f 6e 74 65 78 74 |...//...| context|
|000038b0| 20 6f 63 63 75 72 72 65 | 6e 63 65 20 6e 6f 74 20 | occurre|nce not |
|000038c0| 66 6f 75 6e 64 3a 20 61 | 6e 20 65 6d 70 74 79 20 |found: a|n empty |
|000038d0| 4e 53 74 72 69 6e 67 0d | 09 09 09 2f 2f 09 09 a5 |NString.|...//...|
|000038e0| 20 63 6f 6e 74 65 78 74 | 20 6f 63 63 75 72 72 65 | context| occurre|
|000038f0| 6e 63 65 20 66 6f 75 6e | 64 20 61 6e 64 20 63 6f |nce foun|d and co|
|00003900| 6e 74 65 78 74 20 69 73 | 20 6e 6f 74 20 65 6d 70 |ntext is| not emp|
|00003910| 74 79 20 73 74 72 69 6e | 67 3a 20 22 66 72 6f 6d |ty strin|g: "from|
|00003920| 28 6c 65 66 74 70 6f 73 | 28 63 6f 6e 74 65 78 74 |(leftpos|(context|
|00003930| 29 29 22 0d 09 09 09 2f | 2f 09 09 a5 20 63 6f 6e |))"..../|/... con|
|00003940| 74 65 78 74 20 69 73 20 | 65 6d 70 74 79 20 73 74 |text is |empty st|
|00003950| 72 69 6e 67 3a 20 74 68 | 65 20 65 6e 74 69 72 65 |ring: th|e entire|
|00003960| 20 4e 53 74 72 69 6e 67 | 0d 09 09 09 2f 2f 09 54 | NString|....//.T|
|00003970| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 74 65 73 |he follo|wing tes|
|00003980| 74 20 77 69 6c 6c 20 61 | 6c 77 61 79 73 20 79 69 |t will a|lways yi|
|00003990| 65 6c 64 20 74 72 75 65 | 3a 20 28 73 20 3d 3d 20 |eld true|: (s == |
|000039a0| 73 2e 6c 65 66 74 6f 66 | 28 63 6f 6e 74 65 78 74 |s.leftof|(context|
|000039b0| 29 20 2b 20 73 2e 61 74 | 6c 65 66 74 28 63 6f 6e |) + s.at|left(con|
|000039c0| 74 65 78 74 29 29 0d 0d | 0d 09 09 4e 53 74 72 69 |text))..|...NStri|
|000039d0| 6e 67 20 74 6f 6c 65 66 | 74 20 28 63 6f 6e 73 74 |ng tolef|t (const|
|000039e0| 20 63 68 61 72 20 2a 63 | 6f 6e 74 65 78 74 29 20 | char *c|ontext) |
|000039f0| 63 6f 6e 73 74 3b 09 09 | 09 09 09 09 09 09 09 09 |const;..|........|
|00003a00| 2f 2f 09 09 74 20 3d 20 | 73 2e 74 6f 6c 65 66 74 |//..t = |s.toleft|
|00003a10| 28 22 77 68 69 6c 65 22 | 29 3b 0d 0d 09 09 4e 53 |("while"|);....NS|
|00003a20| 74 72 69 6e 67 20 74 6f | 6c 65 66 74 20 28 63 6f |tring to|left (co|
|00003a30| 6e 73 74 20 63 68 61 72 | 20 63 6f 6e 74 65 78 74 |nst char| context|
|00003a40| 29 20 63 6f 6e 73 74 3b | 09 09 09 09 09 09 09 09 |) const;|........|
|00003a50| 09 09 2f 2f 09 09 74 20 | 3d 20 73 2e 74 6f 6c 65 |..//..t |= s.tole|
|00003a60| 66 74 28 27 77 27 29 3b | 0d 0d 09 09 4e 53 74 72 |ft('w');|....NStr|
|00003a70| 69 6e 67 20 74 6f 6c 65 | 66 74 20 28 63 6f 6e 73 |ing tole|ft (cons|
|00003a80| 74 20 4e 53 74 72 69 6e | 67 26 20 63 6f 6e 74 65 |t NStrin|g& conte|
|00003a90| 78 74 29 20 63 6f 6e 73 | 74 3b 09 09 09 09 09 09 |xt) cons|t;......|
|00003aa0| 09 09 2f 2f 09 09 74 20 | 3d 20 73 2e 74 6f 6c 65 |..//..t |= s.tole|
|00003ab0| 66 74 28 74 29 3b 0d 0d | 09 09 4e 53 74 72 69 6e |ft(t);..|..NStrin|
|00003ac0| 67 20 74 6f 6c 65 66 74 | 20 28 63 6f 6e 73 74 20 |g toleft| (const |
|00003ad0| 41 6c 70 68 61 62 65 74 | 26 20 63 6f 6e 74 65 78 |Alphabet|& contex|
|00003ae0| 74 29 20 63 6f 6e 73 74 | 3b 09 09 09 09 09 09 09 |t) const|;.......|
|00003af0| 09 2f 2f 09 09 74 20 3d | 20 73 2e 74 6f 6c 65 66 |.//..t =| s.tolef|
|00003b00| 74 28 61 6c 70 68 61 29 | 3b 0d 09 09 09 2f 2f 09 |t(alpha)|;....//.|
|00003b10| 72 65 74 75 72 6e 20 74 | 68 65 20 69 6e 69 74 69 |return t|he initi|
|00003b20| 61 6c 20 70 61 72 74 20 | 6f 66 20 74 68 65 20 4e |al part |of the N|
|00003b30| 53 74 72 69 6e 67 20 6a | 75 73 74 20 63 6f 6e 74 |String j|ust cont|
|00003b40| 61 69 6e 69 6e 67 20 74 | 68 65 0d 09 09 09 2f 2f |aining t|he....//|
|00003b50| 09 09 6c 65 66 74 6d 6f | 73 74 20 6f 63 63 75 72 |..leftmo|st occur|
|00003b60| 72 65 6e 63 65 20 6f 66 | 20 74 68 65 20 63 6f 6e |rence of| the con|
|00003b70| 74 65 78 74 2e 0d 09 09 | 09 2f 2f 20 54 68 65 20 |text....|.// The |
|00003b80| 72 65 73 75 6c 74 20 6f | 66 20 74 68 69 73 20 66 |result o|f this f|
|00003b90| 75 6e 63 74 69 6f 6e 20 | 77 69 6c 6c 20 62 65 3a |unction |will be:|
|00003ba0| 0d 09 09 09 2f 2f 09 09 | a5 20 63 6f 6e 74 65 78 |....//..|. contex|
|00003bb0| 74 20 6f 63 63 75 72 72 | 65 6e 63 65 20 6e 6f 74 |t occurr|ence not|
|00003bc0| 20 66 6f 75 6e 64 3a 20 | 74 68 65 20 65 6e 74 69 | found: |the enti|
|00003bd0| 72 65 20 4e 53 74 72 69 | 6e 67 0d 09 09 09 2f 2f |re NStri|ng....//|
|00003be0| 09 09 a5 20 63 6f 6e 74 | 65 78 74 20 6f 63 63 75 |... cont|ext occu|
|00003bf0| 72 72 65 6e 63 65 20 66 | 6f 75 6e 64 20 61 6e 64 |rrence f|ound and|
|00003c00| 20 63 6f 6e 74 65 78 74 | 20 69 73 20 6e 6f 74 20 | context| is not |
|00003c10| 65 6d 70 74 79 20 73 74 | 72 69 6e 67 3a 20 22 74 |empty st|ring: "t|
|00003c20| 6f 28 6c 65 66 74 70 6f | 73 28 63 6f 6e 74 65 78 |o(leftpo|s(contex|
|00003c30| 74 29 20 2b 20 63 6f 6e | 74 65 78 74 5f 6c 65 6e |t) + con|text_len|
|00003c40| 67 74 68 20 2d 20 31 29 | 22 0d 09 09 09 2f 2f 09 |gth - 1)|"....//.|
|00003c50| 09 a5 20 63 6f 6e 74 65 | 78 74 20 69 73 20 65 6d |.. conte|xt is em|
|00003c60| 70 74 79 20 73 74 72 69 | 6e 67 3a 20 61 6e 20 65 |pty stri|ng: an e|
|00003c70| 6d 70 74 79 20 4e 53 74 | 72 69 6e 67 0d 0d 0d 09 |mpty NSt|ring....|
|00003c80| 09 4e 53 74 72 69 6e 67 | 20 6c 65 66 74 63 75 74 |.NString| leftcut|
|00003c90| 20 28 63 6f 6e 73 74 20 | 63 68 61 72 20 2a 63 6f | (const |char *co|
|00003ca0| 6e 74 65 78 74 29 20 63 | 6f 6e 73 74 3b 09 09 09 |ntext) c|onst;...|
|00003cb0| 09 09 09 09 09 09 2f 2f | 09 09 74 20 3d 20 73 2e |......//|..t = s.|
|00003cc0| 6c 65 66 74 63 75 74 28 | 22 77 68 69 6c 65 22 29 |leftcut(|"while")|
|00003cd0| 3b 0d 0d 09 09 4e 53 74 | 72 69 6e 67 20 6c 65 66 |;....NSt|ring lef|
|00003ce0| 74 63 75 74 20 28 63 6f | 6e 73 74 20 63 68 61 72 |tcut (co|nst char|
|00003cf0| 20 63 6f 6e 74 65 78 74 | 29 20 63 6f 6e 73 74 3b | context|) const;|
|00003d00| 09 09 09 09 09 09 09 09 | 09 09 2f 2f 09 09 74 20 |........|..//..t |
|00003d10| 3d 20 73 2e 6c 65 66 74 | 63 75 74 28 27 77 27 29 |= s.left|cut('w')|
|00003d20| 3b 0d 0d 09 09 4e 53 74 | 72 69 6e 67 20 6c 65 66 |;....NSt|ring lef|
|00003d30| 74 63 75 74 20 28 63 6f | 6e 73 74 20 4e 53 74 72 |tcut (co|nst NStr|
|00003d40| 69 6e 67 26 20 63 6f 6e | 74 65 78 74 29 20 63 6f |ing& con|text) co|
|00003d50| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 2f 2f 09 09 |nst;....|....//..|
|00003d60| 74 20 3d 20 73 2e 6c 65 | 66 74 63 75 74 28 74 29 |t = s.le|ftcut(t)|
|00003d70| 3b 0d 0d 09 09 4e 53 74 | 72 69 6e 67 20 6c 65 66 |;....NSt|ring lef|
|00003d80| 74 63 75 74 20 28 63 6f | 6e 73 74 20 41 6c 70 68 |tcut (co|nst Alph|
|00003d90| 61 62 65 74 26 20 63 6f | 6e 74 65 78 74 29 20 63 |abet& co|ntext) c|
|00003da0| 6f 6e 73 74 3b 09 09 09 | 09 09 09 09 09 2f 2f 09 |onst;...|.....//.|
|00003db0| 09 74 20 3d 20 73 2e 6c | 65 66 74 63 75 74 28 61 |.t = s.l|eftcut(a|
|00003dc0| 6c 70 68 61 29 3b 0d 09 | 09 09 2f 2f 09 72 65 74 |lpha);..|..//.ret|
|00003dd0| 75 72 6e 20 74 68 65 20 | 66 69 6e 61 6c 20 70 61 |urn the |final pa|
|00003de0| 72 74 20 6f 66 20 74 68 | 65 20 4e 53 74 72 69 6e |rt of th|e NStrin|
|00003df0| 67 20 73 74 61 72 74 69 | 6e 67 20 61 66 74 65 72 |g starti|ng after|
|00003e00| 0d 09 09 09 2f 2f 09 09 | 61 6e 64 20 6e 6f 74 20 |....//..|and not |
|00003e10| 63 6f 6e 74 61 69 6e 69 | 6e 67 20 74 68 65 20 6c |containi|ng the l|
|00003e20| 65 66 74 6d 6f 73 74 20 | 6f 63 63 75 72 72 65 6e |eftmost |occurren|
|00003e30| 63 65 20 6f 66 20 74 68 | 65 20 63 6f 6e 74 65 78 |ce of th|e contex|
|00003e40| 74 2e 0d 09 09 09 2f 2f | 20 54 68 65 20 72 65 73 |t.....//| The res|
|00003e50| 75 6c 74 20 6f 66 20 74 | 68 69 73 20 66 75 6e 63 |ult of t|his func|
|00003e60| 74 69 6f 6e 20 77 69 6c | 6c 20 62 65 3a 0d 09 09 |tion wil|l be:...|
|00003e70| 09 2f 2f 09 09 a5 20 63 | 6f 6e 74 65 78 74 20 6f |.//... c|ontext o|
|00003e80| 63 63 75 72 72 65 6e 63 | 65 20 6e 6f 74 20 66 6f |ccurrenc|e not fo|
|00003e90| 75 6e 64 3a 20 61 6e 20 | 65 6d 70 74 79 20 4e 53 |und: an |empty NS|
|00003ea0| 74 72 69 6e 67 0d 09 09 | 09 2f 2f 09 09 a5 20 63 |tring...|.//... c|
|00003eb0| 6f 6e 74 65 78 74 20 69 | 73 20 65 6d 70 74 79 20 |ontext i|s empty |
|00003ec0| 73 74 72 69 6e 67 3a 20 | 74 68 65 20 65 6e 74 69 |string: |the enti|
|00003ed0| 72 65 20 4e 53 74 72 69 | 6e 67 0d 09 09 09 2f 2f |re NStri|ng....//|
|00003ee0| 09 09 a5 20 63 6f 6e 74 | 65 78 74 20 6f 63 63 75 |... cont|ext occu|
|00003ef0| 72 72 65 6e 63 65 20 66 | 6f 75 6e 64 20 61 6e 64 |rrence f|ound and|
|00003f00| 20 63 6f 6e 74 65 78 74 | 20 69 73 20 6e 6f 74 20 | context| is not |
|00003f10| 65 6d 70 74 79 20 73 74 | 72 69 6e 67 3a 20 22 66 |empty st|ring: "f|
|00003f20| 72 6f 6d 28 6c 65 66 74 | 70 6f 73 28 63 6f 6e 74 |rom(left|pos(cont|
|00003f30| 65 78 74 29 20 2b 20 63 | 6f 6e 74 65 78 74 5f 6c |ext) + c|ontext_l|
|00003f40| 65 6e 67 74 68 29 22 0d | 09 09 09 2f 2f 09 54 68 |ength)".|...//.Th|
|00003f50| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 74 65 73 74 |e follow|ing test|
|00003f60| 20 77 69 6c 6c 20 61 6c | 77 61 79 73 20 79 69 65 | will al|ways yie|
|00003f70| 6c 64 20 74 72 75 65 3a | 20 28 73 20 3d 3d 20 73 |ld true:| (s == s|
|00003f80| 2e 74 6f 6c 65 66 74 28 | 63 6f 6e 74 65 78 74 29 |.toleft(|context)|
|00003f90| 20 2b 20 73 2e 6c 65 66 | 74 63 75 74 28 63 6f 6e | + s.lef|tcut(con|
|00003fa0| 74 65 78 74 29 29 0d 0d | 0d 09 09 4e 53 74 72 69 |text))..|...NStri|
|00003fb0| 6e 67 20 72 69 67 68 74 | 6f 66 20 28 63 6f 6e 73 |ng right|of (cons|
|00003fc0| 74 20 63 68 61 72 20 2a | 63 6f 6e 74 65 78 74 29 |t char *|context)|
|00003fd0| 20 63 6f 6e 73 74 3b 09 | 09 09 09 09 09 09 09 09 | const;.|........|
|00003fe0| 2f 2f 09 09 74 20 3d 20 | 73 2e 72 69 67 68 74 6f |//..t = |s.righto|
|00003ff0| 66 28 22 62 65 67 69 6e | 22 29 3b 0d 0d 09 09 4e |f("begin|");....N|
|00004000| 53 74 72 69 6e 67 20 72 | 69 67 68 74 6f 66 20 28 |String r|ightof (|
|00004010| 63 6f 6e 73 74 20 63 68 | 61 72 20 63 6f 6e 74 65 |const ch|ar conte|
|00004020| 78 74 29 20 63 6f 6e 73 | 74 3b 09 09 09 09 09 09 |xt) cons|t;......|
|00004030| 09 09 09 2f 2f 09 09 74 | 20 3d 20 73 2e 72 69 67 |...//..t| = s.rig|
|00004040| 68 74 6f 66 28 27 62 27 | 29 3b 0d 0d 09 09 4e 53 |htof('b'|);....NS|
|00004050| 74 72 69 6e 67 20 72 69 | 67 68 74 6f 66 20 28 63 |tring ri|ghtof (c|
|00004060| 6f 6e 73 74 20 4e 53 74 | 72 69 6e 67 26 20 63 6f |onst NSt|ring& co|
|00004070| 6e 74 65 78 74 29 20 63 | 6f 6e 73 74 3b 09 09 09 |ntext) c|onst;...|
|00004080| 09 09 09 09 09 2f 2f 09 | 09 74 20 3d 20 73 2e 72 |.....//.|.t = s.r|
|00004090| 69 67 68 74 6f 66 28 74 | 29 3b 0d 0d 09 09 4e 53 |ightof(t|);....NS|
|000040a0| 74 72 69 6e 67 20 72 69 | 67 68 74 6f 66 20 28 63 |tring ri|ghtof (c|
|000040b0| 6f 6e 73 74 20 41 6c 70 | 68 61 62 65 74 26 20 63 |onst Alp|habet& c|
|000040c0| 6f 6e 74 65 78 74 29 20 | 63 6f 6e 73 74 3b 09 09 |ontext) |const;..|
|000040d0| 09 09 09 09 09 2f 2f 09 | 09 74 20 3d 20 73 2e 72 |.....//.|.t = s.r|
|000040e0| 69 67 68 74 6f 66 28 61 | 6c 70 68 61 29 3b 0d 09 |ightof(a|lpha);..|
|000040f0| 09 09 2f 2f 09 72 65 74 | 75 72 6e 20 74 68 65 20 |..//.ret|urn the |
|00004100| 66 69 6e 61 6c 20 70 61 | 72 74 20 6f 66 20 74 68 |final pa|rt of th|
|00004110| 65 20 4e 53 74 72 69 6e | 67 20 6e 6f 74 20 63 6f |e NStrin|g not co|
|00004120| 6e 74 61 69 6e 69 6e 67 | 0d 09 09 09 2f 2f 09 09 |ntaining|....//..|
|00004130| 74 68 65 20 72 69 67 68 | 74 6d 6f 73 74 20 63 6f |the righ|tmost co|
|00004140| 6e 74 65 78 74 20 6f 63 | 63 75 72 72 65 6e 63 65 |ntext oc|currence|
|00004150| 2e 0d 09 09 09 2f 2f 20 | 54 68 65 20 72 65 73 75 |.....// |The resu|
|00004160| 6c 74 20 6f 66 20 74 68 | 69 73 20 66 75 6e 63 74 |lt of th|is funct|
|00004170| 69 6f 6e 20 77 69 6c 6c | 20 62 65 3a 0d 09 09 09 |ion will| be:....|
|00004180| 2f 2f 09 09 a5 20 63 6f | 6e 74 65 78 74 20 6f 63 |//... co|ntext oc|
|00004190| 63 75 72 72 65 6e 63 65 | 20 6e 6f 74 20 66 6f 75 |currence| not fou|
|000041a0| 6e 64 3a 20 74 68 65 20 | 65 6e 74 69 72 65 20 4e |nd: the |entire N|
|000041b0| 53 74 72 69 6e 67 0d 09 | 09 09 2f 2f 09 09 a5 20 |String..|..//... |
|000041c0| 63 6f 6e 74 65 78 74 20 | 6f 63 63 75 72 72 65 6e |context |occurren|
|000041d0| 63 65 20 61 74 20 74 68 | 65 20 65 6e 64 20 6f 66 |ce at th|e end of|
|000041e0| 20 74 68 65 20 73 74 72 | 69 6e 67 3a 20 61 6e 20 | the str|ing: an |
|000041f0| 65 6d 70 74 79 20 4e 53 | 74 72 69 6e 67 0d 09 09 |empty NS|tring...|
|00004200| 09 2f 2f 09 09 a5 20 63 | 6f 6e 74 65 78 74 20 6f |.//... c|ontext o|
|00004210| 63 63 75 72 72 65 6e 63 | 65 20 6e 6f 74 20 65 6e |ccurrenc|e not en|
|00004220| 64 69 6e 67 20 74 68 65 | 20 73 74 72 69 6e 67 3a |ding the| string:|
|00004230| 20 22 66 72 6f 6d 28 72 | 69 67 68 74 70 6f 73 28 | "from(r|ightpos(|
|00004240| 63 6f 6e 74 65 78 74 29 | 20 2b 20 63 6f 6e 74 65 |context)| + conte|
|00004250| 78 74 5f 6c 65 6e 67 74 | 68 29 22 0d 0d 0d 09 09 |xt_lengt|h)".....|
|00004260| 4e 53 74 72 69 6e 67 20 | 61 74 72 69 67 68 74 20 |NString |atright |
|00004270| 28 63 6f 6e 73 74 20 63 | 68 61 72 20 2a 63 6f 6e |(const c|har *con|
|00004280| 74 65 78 74 29 20 63 6f | 6e 73 74 3b 09 09 09 09 |text) co|nst;....|
|00004290| 09 09 09 09 09 2f 2f 09 | 09 74 20 3d 20 73 2e 61 |.....//.|.t = s.a|
|000042a0| 74 72 69 67 68 74 28 22 | 62 65 67 69 6e 22 29 3b |tright("|begin");|
|000042b0| 0d 0d 09 09 4e 53 74 72 | 69 6e 67 20 61 74 72 69 |....NStr|ing atri|
|000042c0| 67 68 74 20 28 63 6f 6e | 73 74 20 63 68 61 72 20 |ght (con|st char |
|000042d0| 63 6f 6e 74 65 78 74 29 | 20 63 6f 6e 73 74 3b 09 |context)| const;.|
|000042e0| 09 09 09 09 09 09 09 09 | 2f 2f 09 09 74 20 3d 20 |........|//..t = |
|000042f0| 73 2e 61 74 72 69 67 68 | 74 28 27 62 27 29 3b 0d |s.atrigh|t('b');.|
|00004300| 09 09 0d 09 09 4e 53 74 | 72 69 6e 67 20 61 74 72 |.....NSt|ring atr|
|00004310| 69 67 68 74 20 28 63 6f | 6e 73 74 20 4e 53 74 72 |ight (co|nst NStr|
|00004320| 69 6e 67 26 20 63 6f 6e | 74 65 78 74 29 20 63 6f |ing& con|text) co|
|00004330| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 2f 2f 09 09 |nst;....|....//..|
|00004340| 74 20 3d 20 73 2e 61 74 | 72 69 67 68 74 28 74 29 |t = s.at|right(t)|
|00004350| 3b 0d 0d 09 09 4e 53 74 | 72 69 6e 67 20 61 74 72 |;....NSt|ring atr|
|00004360| 69 67 68 74 20 28 63 6f | 6e 73 74 20 41 6c 70 68 |ight (co|nst Alph|
|00004370| 61 62 65 74 26 20 63 6f | 6e 74 65 78 74 29 20 63 |abet& co|ntext) c|
|00004380| 6f 6e 73 74 3b 09 09 09 | 09 09 09 09 2f 2f 09 09 |onst;...|....//..|
|00004390| 74 20 3d 20 73 2e 61 74 | 72 69 67 68 74 28 61 6c |t = s.at|right(al|
|000043a0| 70 68 61 29 3b 0d 09 09 | 09 2f 2f 09 72 65 74 75 |pha);...|.//.retu|
|000043b0| 72 6e 20 74 68 65 20 66 | 69 6e 61 6c 20 70 61 72 |rn the f|inal par|
|000043c0| 74 20 6f 66 20 74 68 65 | 20 4e 53 74 72 69 6e 67 |t of the| NString|
|000043d0| 20 73 74 61 72 74 69 6e | 67 20 61 74 20 74 68 65 | startin|g at the|
|000043e0| 20 70 6f 73 69 74 69 6f | 6e 20 6f 66 0d 09 09 09 | positio|n of....|
|000043f0| 2f 2f 09 09 74 68 65 20 | 72 69 67 68 74 6d 6f 73 |//..the |rightmos|
|00004400| 74 20 63 6f 6e 74 65 78 | 74 20 6f 63 63 75 72 72 |t contex|t occurr|
|00004410| 65 6e 63 65 2e 0d 09 09 | 09 2f 2f 20 54 68 65 20 |ence....|.// The |
|00004420| 72 65 73 75 6c 74 20 6f | 66 20 74 68 69 73 20 66 |result o|f this f|
|00004430| 75 6e 63 74 69 6f 6e 20 | 77 69 6c 6c 20 62 65 3a |unction |will be:|
|00004440| 0d 09 09 09 2f 2f 09 09 | a5 20 63 6f 6e 74 65 78 |....//..|. contex|
|00004450| 74 20 6f 63 63 75 72 72 | 65 6e 63 65 20 6e 6f 74 |t occurr|ence not|
|00004460| 20 66 6f 75 6e 64 3a 20 | 74 68 65 20 65 6e 74 69 | found: |the enti|
|00004470| 72 65 20 4e 53 74 72 69 | 6e 67 0d 09 09 09 2f 2f |re NStri|ng....//|
|00004480| 09 09 a5 20 63 6f 6e 74 | 65 78 74 20 6f 63 63 75 |... cont|ext occu|
|00004490| 72 72 65 6e 63 65 20 66 | 6f 75 6e 64 20 61 6e 64 |rrence f|ound and|
|000044a0| 20 63 6f 6e 74 65 78 74 | 20 69 73 20 6e 6f 74 20 | context| is not |
|000044b0| 65 6d 70 74 79 20 73 74 | 72 69 6e 67 3a 20 22 66 |empty st|ring: "f|
|000044c0| 72 6f 6d 28 72 69 67 68 | 74 70 6f 73 28 63 6f 6e |rom(righ|tpos(con|
|000044d0| 74 65 78 74 29 29 22 0d | 09 09 09 2f 2f 09 09 a5 |text))".|...//...|
|000044e0| 20 63 6f 6e 74 65 78 74 | 20 69 73 20 65 6d 70 74 | context| is empt|
|000044f0| 79 20 73 74 72 69 6e 67 | 3a 20 61 6e 20 65 6d 70 |y string|: an emp|
|00004500| 74 79 20 4e 53 74 72 69 | 6e 67 0d 0d 0d 09 09 4e |ty NStri|ng.....N|
|00004510| 53 74 72 69 6e 67 20 74 | 6f 72 69 67 68 74 20 28 |String t|oright (|
|00004520| 63 6f 6e 73 74 20 63 68 | 61 72 20 2a 63 6f 6e 74 |const ch|ar *cont|
|00004530| 65 78 74 29 20 63 6f 6e | 73 74 3b 09 09 09 09 09 |ext) con|st;.....|
|00004540| 09 09 09 09 2f 2f 09 09 | 74 20 3d 20 73 2e 74 6f |....//..|t = s.to|
|00004550| 72 69 67 68 74 28 22 77 | 68 69 6c 65 22 29 3b 0d |right("w|hile");.|
|00004560| 0d 09 09 4e 53 74 72 69 | 6e 67 20 74 6f 72 69 67 |...NStri|ng torig|
|00004570| 68 74 20 28 63 6f 6e 73 | 74 20 63 68 61 72 20 63 |ht (cons|t char c|
|00004580| 6f 6e 74 65 78 74 29 20 | 63 6f 6e 73 74 3b 09 09 |ontext) |const;..|
|00004590| 09 09 09 09 09 09 09 2f | 2f 09 09 74 20 3d 20 73 |......./|/..t = s|
|000045a0| 2e 74 6f 72 69 67 68 74 | 28 27 77 27 29 3b 0d 0d |.toright|('w');..|
|000045b0| 09 09 4e 53 74 72 69 6e | 67 20 74 6f 72 69 67 68 |..NStrin|g torigh|
|000045c0| 74 20 28 63 6f 6e 73 74 | 20 4e 53 74 72 69 6e 67 |t (const| NString|
|000045d0| 26 20 63 6f 6e 74 65 78 | 74 29 20 63 6f 6e 73 74 |& contex|t) const|
|000045e0| 3b 09 09 09 09 09 09 09 | 09 2f 2f 09 09 74 20 3d |;.......|.//..t =|
|000045f0| 20 73 2e 74 6f 72 69 67 | 68 74 28 74 29 3b 0d 0d | s.torig|ht(t);..|
|00004600| 09 09 4e 53 74 72 69 6e | 67 20 74 6f 72 69 67 68 |..NStrin|g torigh|
|00004610| 74 20 28 63 6f 6e 73 74 | 20 41 6c 70 68 61 62 65 |t (const| Alphabe|
|00004620| 74 26 20 63 6f 6e 74 65 | 78 74 29 20 63 6f 6e 73 |t& conte|xt) cons|
|00004630| 74 3b 09 09 09 09 09 09 | 09 2f 2f 09 09 74 20 3d |t;......|.//..t =|
|00004640| 20 73 2e 74 6f 72 69 67 | 68 74 28 61 6c 70 68 61 | s.torig|ht(alpha|
|00004650| 29 3b 0d 09 09 09 2f 2f | 09 72 65 74 75 72 6e 20 |);....//|.return |
|00004660| 74 68 65 20 69 6e 69 74 | 69 61 6c 20 70 61 72 74 |the init|ial part|
|00004670| 20 6f 66 20 74 68 65 20 | 4e 53 74 72 69 6e 67 20 | of the |NString |
|00004680| 6a 75 73 74 20 63 6f 6e | 74 61 69 6e 69 6e 67 20 |just con|taining |
|00004690| 74 68 65 0d 09 09 09 2f | 2f 09 09 72 69 67 68 74 |the..../|/..right|
|000046a0| 6d 6f 73 74 20 6f 63 63 | 75 72 72 65 6e 63 65 20 |most occ|urrence |
|000046b0| 6f 66 20 74 68 65 20 63 | 6f 6e 74 65 78 74 2e 0d |of the c|ontext..|
|000046c0| 09 09 09 2f 2f 20 54 68 | 65 20 72 65 73 75 6c 74 |...// Th|e result|
|000046d0| 20 6f 66 20 74 68 69 73 | 20 66 75 6e 63 74 69 6f | of this| functio|
|000046e0| 6e 20 77 69 6c 6c 20 62 | 65 3a 0d 09 09 09 2f 2f |n will b|e:....//|
|000046f0| 09 09 a5 20 63 6f 6e 74 | 65 78 74 20 6f 63 63 75 |... cont|ext occu|
|00004700| 72 72 65 6e 63 65 20 6e | 6f 74 20 66 6f 75 6e 64 |rrence n|ot found|
|00004710| 3a 20 61 6e 20 65 6d 70 | 74 79 20 4e 53 74 72 69 |: an emp|ty NStri|
|00004720| 6e 67 0d 09 09 09 2f 2f | 09 09 a5 20 63 6f 6e 74 |ng....//|... cont|
|00004730| 65 78 74 20 6f 63 63 75 | 72 72 65 6e 63 65 20 66 |ext occu|rrence f|
|00004740| 6f 75 6e 64 20 61 6e 64 | 20 63 6f 6e 74 65 78 74 |ound and| context|
|00004750| 20 69 73 20 6e 6f 74 20 | 65 6d 70 74 79 20 73 74 | is not |empty st|
|00004760| 72 69 6e 67 3a 20 22 74 | 6f 28 72 69 67 68 74 70 |ring: "t|o(rightp|
|00004770| 6f 73 28 63 6f 6e 74 65 | 78 74 29 20 2b 20 63 6f |os(conte|xt) + co|
|00004780| 6e 74 65 78 74 5f 6c 65 | 6e 67 74 68 20 2d 20 31 |ntext_le|ngth - 1|
|00004790| 29 22 0d 09 09 09 2f 2f | 09 09 a5 20 63 6f 6e 74 |)"....//|... cont|
|000047a0| 65 78 74 20 69 73 20 65 | 6d 70 74 79 20 73 74 72 |ext is e|mpty str|
|000047b0| 69 6e 67 3a 20 74 68 65 | 20 65 6e 74 69 72 65 20 |ing: the| entire |
|000047c0| 4e 53 74 72 69 6e 67 0d | 09 09 09 2f 2f 09 54 68 |NString.|...//.Th|
|000047d0| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 74 65 73 74 |e follow|ing test|
|000047e0| 20 77 69 6c 6c 20 61 6c | 77 61 79 73 20 79 69 65 | will al|ways yie|
|000047f0| 6c 64 20 74 72 75 65 3a | 20 28 73 20 3d 3d 20 73 |ld true:| (s == s|
|00004800| 2e 74 6f 72 69 67 68 74 | 28 63 6f 6e 74 65 78 74 |.toright|(context|
|00004810| 29 20 2b 20 73 2e 72 69 | 67 68 74 6f 66 28 63 6f |) + s.ri|ghtof(co|
|00004820| 6e 74 65 78 74 29 29 0d | 0d 0d 09 09 4e 53 74 72 |ntext)).|....NStr|
|00004830| 69 6e 67 20 72 69 67 68 | 74 63 75 74 20 28 63 6f |ing righ|tcut (co|
|00004840| 6e 73 74 20 63 68 61 72 | 20 2a 63 6f 6e 74 65 78 |nst char| *contex|
|00004850| 74 29 20 63 6f 6e 73 74 | 3b 09 09 09 09 09 09 09 |t) const|;.......|
|00004860| 09 09 2f 2f 09 09 74 20 | 3d 20 73 2e 72 69 67 68 |..//..t |= s.righ|
|00004870| 74 63 75 74 28 22 77 68 | 69 6c 65 22 29 3b 0d 0d |tcut("wh|ile");..|
|00004880| 09 09 4e 53 74 72 69 6e | 67 20 72 69 67 68 74 63 |..NStrin|g rightc|
|00004890| 75 74 20 28 63 6f 6e 73 | 74 20 63 68 61 72 20 63 |ut (cons|t char c|
|000048a0| 6f 6e 74 65 78 74 29 20 | 63 6f 6e 73 74 3b 09 09 |ontext) |const;..|
|000048b0| 09 09 09 09 09 09 09 2f | 2f 09 09 74 20 3d 20 73 |......./|/..t = s|
|000048c0| 2e 72 69 67 68 74 63 75 | 74 28 27 77 27 29 3b 0d |.rightcu|t('w');.|
|000048d0| 0d 09 09 4e 53 74 72 69 | 6e 67 20 72 69 67 68 74 |...NStri|ng right|
|000048e0| 63 75 74 20 28 63 6f 6e | 73 74 20 4e 53 74 72 69 |cut (con|st NStri|
|000048f0| 6e 67 26 20 63 6f 6e 74 | 65 78 74 29 20 63 6f 6e |ng& cont|ext) con|
|00004900| 73 74 3b 09 09 09 09 09 | 09 09 2f 2f 09 09 74 20 |st;.....|..//..t |
|00004910| 3d 20 73 2e 72 69 67 68 | 74 63 75 74 28 74 29 3b |= s.righ|tcut(t);|
|00004920| 0d 0d 09 09 4e 53 74 72 | 69 6e 67 20 72 69 67 68 |....NStr|ing righ|
|00004930| 74 63 75 74 20 28 63 6f | 6e 73 74 20 41 6c 70 68 |tcut (co|nst Alph|
|00004940| 61 62 65 74 26 20 63 6f | 6e 74 65 78 74 29 20 63 |abet& co|ntext) c|
|00004950| 6f 6e 73 74 3b 09 09 09 | 09 09 09 09 2f 2f 09 09 |onst;...|....//..|
|00004960| 74 20 3d 20 73 2e 72 69 | 67 68 74 63 75 74 28 61 |t = s.ri|ghtcut(a|
|00004970| 6c 70 68 61 29 3b 0d 09 | 09 09 2f 2f 09 72 65 74 |lpha);..|..//.ret|
|00004980| 75 72 6e 20 74 68 65 20 | 69 6e 69 74 69 61 6c 20 |urn the |initial |
|00004990| 70 61 72 74 20 6f 66 20 | 74 68 65 20 4e 53 74 72 |part of |the NStr|
|000049a0| 69 6e 67 20 65 6e 64 69 | 6e 67 20 61 74 0d 09 09 |ing endi|ng at...|
|000049b0| 09 2f 2f 09 09 61 6e 64 | 20 6e 6f 74 20 63 6f 6e |.//..and| not con|
|000049c0| 74 61 69 6e 69 6e 67 20 | 74 68 65 20 72 69 67 68 |taining |the righ|
|000049d0| 74 6d 6f 73 74 20 6f 63 | 63 75 72 72 65 6e 63 65 |tmost oc|currence|
|000049e0| 20 6f 66 20 74 68 65 20 | 63 6f 6e 74 65 78 74 2e | of the |context.|
|000049f0| 0d 09 09 09 2f 2f 20 54 | 68 65 20 72 65 73 75 6c |....// T|he resul|
|00004a00| 74 20 6f 66 20 74 68 69 | 73 20 66 75 6e 63 74 69 |t of thi|s functi|
|00004a10| 6f 6e 20 77 69 6c 6c 20 | 62 65 3a 0d 09 09 09 2f |on will |be:..../|
|00004a20| 2f 09 09 a5 20 63 6f 6e | 74 65 78 74 20 6f 63 63 |/... con|text occ|
|00004a30| 75 72 72 65 6e 63 65 20 | 6e 6f 74 20 66 6f 75 6e |urrence |not foun|
|00004a40| 64 3a 20 61 6e 20 65 6d | 70 74 79 20 4e 53 74 72 |d: an em|pty NStr|
|00004a50| 69 6e 67 0d 09 09 09 2f | 2f 09 09 a5 20 63 6f 6e |ing..../|/... con|
|00004a60| 74 65 78 74 20 6f 63 63 | 75 72 72 65 6e 63 65 20 |text occ|urrence |
|00004a70| 66 6f 75 6e 64 20 61 74 | 20 74 68 65 20 62 65 67 |found at| the beg|
|00004a80| 69 6e 6e 69 6e 67 20 6f | 66 20 74 68 65 20 73 74 |inning o|f the st|
|00004a90| 72 69 6e 67 3a 20 61 6e | 20 65 6d 70 74 79 20 4e |ring: an| empty N|
|00004aa0| 53 74 72 69 6e 67 0d 09 | 09 09 2f 2f 09 09 a5 20 |String..|..//... |
|00004ab0| 63 6f 6e 74 65 78 74 20 | 69 73 20 65 6d 70 74 79 |context |is empty|
|00004ac0| 20 73 74 72 69 6e 67 3a | 20 74 68 65 20 65 6e 74 | string:| the ent|
|00004ad0| 69 72 65 20 4e 53 74 72 | 69 6e 67 0d 09 09 09 2f |ire NStr|ing..../|
|00004ae0| 2f 09 09 a5 20 63 6f 6e | 74 65 78 74 20 6f 63 63 |/... con|text occ|
|00004af0| 75 72 72 65 6e 63 65 20 | 66 6f 75 6e 64 20 61 6e |urrence |found an|
|00004b00| 64 20 63 6f 6e 74 65 78 | 74 20 69 73 20 6e 6f 74 |d contex|t is not|
|00004b10| 20 65 6d 70 74 79 20 73 | 74 72 69 6e 67 3a 20 22 | empty s|tring: "|
|00004b20| 74 6f 28 72 69 67 68 74 | 70 6f 73 28 63 6f 6e 74 |to(right|pos(cont|
|00004b30| 65 78 74 29 20 2d 20 31 | 29 22 0d 09 09 09 2f 2f |ext) - 1|)"....//|
|00004b40| 09 54 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 74 |.The fol|lowing t|
|00004b50| 65 73 74 20 77 69 6c 6c | 20 61 6c 77 61 79 73 20 |est will| always |
|00004b60| 79 69 65 6c 64 20 74 72 | 75 65 3a 20 28 73 20 3d |yield tr|ue: (s =|
|00004b70| 3d 20 73 2e 72 69 67 68 | 74 63 75 74 28 63 6f 6e |= s.righ|tcut(con|
|00004b80| 74 65 78 74 29 20 2b 20 | 73 2e 61 74 72 69 67 68 |text) + |s.atrigh|
|00004b90| 74 28 63 6f 6e 74 65 78 | 74 29 29 0d 0d 0d 09 09 |t(contex|t)).....|
|00004ba0| 69 6e 6c 69 6e 65 20 63 | 68 61 72 20 6c 65 66 74 |inline c|har left|
|00004bb0| 6f 63 63 20 28 63 6f 6e | 73 74 20 41 6c 70 68 61 |occ (con|st Alpha|
|00004bc0| 62 65 74 26 20 61 29 20 | 63 6f 6e 73 74 3b 09 09 |bet& a) |const;..|
|00004bd0| 09 09 09 09 09 09 09 2f | 2f 09 09 63 20 3d 20 73 |......./|/..c = s|
|00004be0| 2e 6c 65 66 74 6f 63 63 | 28 41 6c 70 68 61 62 65 |.leftocc|(Alphabe|
|00004bf0| 74 28 22 61 62 63 22 29 | 29 3b 0d 09 09 09 2f 2f |t("abc")|);....//|
|00004c00| 20 6f 66 20 74 68 65 20 | 6c 65 74 74 65 72 73 20 | of the |letters |
|00004c10| 63 6f 6e 74 61 69 6e 65 | 64 20 69 6e 20 74 68 65 |containe|d in the|
|00004c20| 20 61 6c 70 68 61 62 65 | 74 2c 20 72 65 74 75 72 | alphabe|t, retur|
|00004c30| 6e 20 74 68 65 20 6f 6e | 65 20 74 68 61 74 20 0d |n the on|e that .|
|00004c40| 09 09 09 2f 2f 09 09 68 | 61 73 20 74 68 65 20 6c |...//..h|as the l|
|00004c50| 65 66 74 6d 6f 73 74 20 | 70 6f 73 69 74 69 6f 6e |eftmost |position|
|00004c60| 20 69 6e 20 74 68 65 20 | 4e 53 74 72 69 6e 67 2e | in the |NString.|
|00004c70| 20 49 66 20 74 68 65 72 | 65 20 69 73 20 6e 6f 20 | If ther|e is no |
|00004c80| 73 75 63 68 20 6c 65 74 | 74 65 72 0d 09 09 09 2f |such let|ter..../|
|00004c90| 2f 09 09 69 6e 20 74 68 | 65 20 61 6c 70 68 61 62 |/..in th|e alphab|
|00004ca0| 65 74 2c 20 74 68 65 20 | 4e 55 4c 2d 63 68 61 72 |et, the |NUL-char|
|00004cb0| 61 63 74 65 72 20 28 27 | 5c 30 27 29 20 69 73 20 |acter ('|\0') is |
|00004cc0| 72 65 74 75 72 6e 65 64 | 2c 20 61 73 20 74 68 69 |returned|, as thi|
|00004cd0| 73 0d 09 09 09 2f 2f 09 | 09 63 68 61 72 61 63 74 |s....//.|.charact|
|00004ce0| 65 72 20 63 61 6e 6e 6f | 74 20 62 65 20 70 61 72 |er canno|t be par|
|00004cf0| 74 20 6f 66 20 61 6e 79 | 20 4e 53 74 72 69 6e 67 |t of any| NString|
|00004d00| 2e 0d 0d 09 09 69 6e 6c | 69 6e 65 20 63 68 61 72 |.....inl|ine char|
|00004d10| 20 72 69 67 68 74 6f 63 | 63 20 28 63 6f 6e 73 74 | rightoc|c (const|
|00004d20| 20 41 6c 70 68 61 62 65 | 74 26 20 61 29 20 63 6f | Alphabe|t& a) co|
|00004d30| 6e 73 74 3b 09 09 09 09 | 09 09 09 09 2f 2f 09 09 |nst;....|....//..|
|00004d40| 63 20 3d 20 73 2e 72 69 | 67 68 74 6f 63 63 28 41 |c = s.ri|ghtocc(A|
|00004d50| 6c 70 68 61 62 65 74 28 | 22 61 62 63 22 29 29 3b |lphabet(|"abc"));|
|00004d60| 0d 09 09 09 2f 2f 20 6f | 66 20 74 68 65 20 6c 65 |....// o|f the le|
|00004d70| 74 74 65 72 73 20 63 6f | 6e 74 61 69 6e 65 64 20 |tters co|ntained |
|00004d80| 69 6e 20 74 68 65 20 61 | 6c 70 68 61 62 65 74 2c |in the a|lphabet,|
|00004d90| 20 72 65 74 75 72 6e 20 | 74 68 65 20 6f 6e 65 20 | return |the one |
|00004da0| 74 68 61 74 20 0d 09 09 | 09 2f 2f 09 09 68 61 73 |that ...|.//..has|
|00004db0| 20 74 68 65 20 72 69 67 | 68 74 6d 6f 73 74 20 70 | the rig|htmost p|
|00004dc0| 6f 73 69 74 69 6f 6e 20 | 69 6e 20 74 68 65 20 4e |osition |in the N|
|00004dd0| 53 74 72 69 6e 67 2e 20 | 49 66 20 74 68 65 72 65 |String. |If there|
|00004de0| 20 69 73 20 6e 6f 20 73 | 75 63 68 20 6c 65 74 74 | is no s|uch lett|
|00004df0| 65 72 0d 09 09 09 2f 2f | 09 09 69 6e 20 74 68 65 |er....//|..in the|
|00004e00| 20 61 6c 70 68 61 62 65 | 74 2c 20 74 68 65 20 4e | alphabe|t, the N|
|00004e10| 55 4c 2d 63 68 61 72 61 | 63 74 65 72 20 28 27 5c |UL-chara|cter ('\|
|00004e20| 30 27 29 20 69 73 20 72 | 65 74 75 72 6e 65 64 2c |0') is r|eturned,|
|00004e30| 20 61 73 20 74 68 69 73 | 0d 09 09 09 2f 2f 09 09 | as this|....//..|
|00004e40| 63 68 61 72 61 63 74 65 | 72 20 63 61 6e 6e 6f 74 |characte|r cannot|
|00004e50| 20 62 65 20 70 61 72 74 | 20 6f 66 20 61 6e 79 20 | be part| of any |
|00004e60| 4e 53 74 72 69 6e 67 2e | 0d 0d 0d 09 09 66 72 69 |NString.|.....fri|
|00004e70| 65 6e 64 20 4e 53 74 72 | 69 6e 67 20 73 70 61 6e |end NStr|ing span|
|00004e80| 20 28 63 6f 6e 73 74 20 | 63 68 61 72 20 63 6f 6e | (const |char con|
|00004e90| 74 65 78 74 2c 20 63 6f | 6e 73 74 20 4e 53 74 72 |text, co|nst NStr|
|00004ea0| 69 6e 67 26 20 73 29 3b | 09 09 09 09 2f 2f 09 09 |ing& s);|....//..|
|00004eb0| 74 20 3d 20 73 70 61 6e | 28 27 2d 27 2c 20 73 29 |t = span|('-', s)|
|00004ec0| 3b 0d 0d 09 09 66 72 69 | 65 6e 64 20 4e 53 74 72 |;....fri|end NStr|
|00004ed0| 69 6e 67 20 73 70 61 6e | 20 28 63 6f 6e 73 74 20 |ing span| (const |
|00004ee0| 41 6c 70 68 61 62 65 74 | 26 20 63 6f 6e 74 65 78 |Alphabet|& contex|
|00004ef0| 74 2c 20 63 6f 6e 73 74 | 20 4e 53 74 72 69 6e 67 |t, const| NString|
|00004f00| 26 20 73 29 3b 09 09 2f | 2f 09 09 74 20 3d 20 73 |& s);../|/..t = s|
|00004f10| 70 61 6e 28 61 6c 70 68 | 61 2c 20 73 29 3b 0d 09 |pan(alph|a, s);..|
|00004f20| 09 09 2f 2f 09 72 65 74 | 75 72 6e 20 74 68 65 20 |..//.ret|urn the |
|00004f30| 69 6e 69 74 69 61 6c 20 | 73 75 62 73 74 72 69 6e |initial |substrin|
|00004f40| 67 20 6f 66 20 74 68 65 | 20 4e 53 74 72 69 6e 67 |g of the| NString|
|00004f50| 20 22 73 22 20 74 68 61 | 74 0d 09 09 09 2f 2f 09 | "s" tha|t....//.|
|00004f60| 09 63 6f 6e 73 69 73 74 | 73 20 6f 66 20 6e 6f 74 |.consist|s of not|
|00004f70| 68 69 6e 67 20 62 75 74 | 20 22 63 6f 6e 74 65 78 |hing but| "contex|
|00004f80| 74 22 2d 63 68 61 72 61 | 63 74 65 72 73 2e 0d 09 |t"-chara|cters...|
|00004f90| 09 09 2f 2f 20 65 2e 67 | 3a 20 73 70 61 6e 28 22 |..// e.g|: span("|
|00004fa0| 2d 22 2c 20 4e 53 74 72 | 69 6e 67 28 22 2d 2d 54 |-", NStr|ing("--T|
|00004fb0| 65 73 74 3d 3d 22 29 29 | 20 77 6f 75 6c 64 20 72 |est=="))| would r|
|00004fc0| 65 74 75 72 6e 20 22 2d | 2d 22 2e 0d 0d 09 09 66 |eturn "-|-".....f|
|00004fd0| 72 69 65 6e 64 20 4e 53 | 74 72 69 6e 67 20 73 70 |riend NS|tring sp|
|00004fe0| 61 6e 20 28 63 6f 6e 73 | 74 20 4e 53 74 72 69 6e |an (cons|t NStrin|
|00004ff0| 67 26 20 73 2c 20 63 6f | 6e 73 74 20 63 68 61 72 |g& s, co|nst char|
|00005000| 20 63 6f 6e 74 65 78 74 | 29 3b 09 09 09 09 2f 2f | context|);....//|
|00005010| 09 09 74 20 3d 20 73 70 | 61 6e 28 73 2c 20 27 2a |..t = sp|an(s, '*|
|00005020| 27 29 3b 0d 0d 09 09 66 | 72 69 65 6e 64 20 4e 53 |');....f|riend NS|
|00005030| 74 72 69 6e 67 20 73 70 | 61 6e 20 28 63 6f 6e 73 |tring sp|an (cons|
|00005040| 74 20 4e 53 74 72 69 6e | 67 26 20 73 2c 20 63 6f |t NStrin|g& s, co|
|00005050| 6e 73 74 20 41 6c 70 68 | 61 62 65 74 26 20 63 6f |nst Alph|abet& co|
|00005060| 6e 74 65 78 74 29 3b 09 | 09 2f 2f 09 09 74 20 3d |ntext);.|.//..t =|
|00005070| 20 73 70 61 6e 28 73 2c | 20 61 6c 70 68 61 29 3b | span(s,| alpha);|
|00005080| 0d 09 09 09 2f 2f 09 72 | 65 74 75 72 6e 20 74 68 |....//.r|eturn th|
|00005090| 65 20 66 69 6e 61 6c 20 | 73 75 62 73 74 72 69 6e |e final |substrin|
|000050a0| 67 20 6f 66 20 74 68 65 | 20 4e 53 74 72 69 6e 67 |g of the| NString|
|000050b0| 20 22 73 22 20 74 68 61 | 74 0d 09 09 09 2f 2f 09 | "s" tha|t....//.|
|000050c0| 09 63 6f 6e 73 69 73 74 | 73 20 6f 66 20 6e 6f 74 |.consist|s of not|
|000050d0| 68 69 6e 67 20 62 75 74 | 20 22 63 6f 6e 74 65 78 |hing but| "contex|
|000050e0| 74 22 2d 63 68 61 72 61 | 63 74 65 72 73 2e 0d 09 |t"-chara|cters...|
|000050f0| 09 09 0d 09 09 09 0d 09 | 09 66 72 69 65 6e 64 20 |........|.friend |
|00005100| 4e 53 74 72 69 6e 67 20 | 6f 70 65 72 61 74 6f 72 |NString |operator|
|00005110| 2d 20 28 63 6f 6e 73 74 | 20 63 68 61 72 20 63 2c |- (const| char c,|
|00005120| 20 63 6f 6e 73 74 20 4e | 53 74 72 69 6e 67 26 20 | const N|String& |
|00005130| 73 29 3b 09 09 09 09 2f | 2f 09 09 74 20 3d 20 27 |s);..../|/..t = '|
|00005140| 2a 27 20 2d 20 73 3b 0d | 0d 09 09 66 72 69 65 6e |*' - s;.|...frien|
|00005150| 64 20 4e 53 74 72 69 6e | 67 20 6f 70 65 72 61 74 |d NStrin|g operat|
|00005160| 6f 72 2d 20 28 63 6f 6e | 73 74 20 41 6c 70 68 61 |or- (con|st Alpha|
|00005170| 62 65 74 26 20 63 74 78 | 2c 20 63 6f 6e 73 74 20 |bet& ctx|, const |
|00005180| 4e 53 74 72 69 6e 67 26 | 20 73 29 3b 09 2f 2f 09 |NString&| s);.//.|
|00005190| 09 74 20 3d 20 61 6c 70 | 68 61 20 2d 20 73 3b 0d |.t = alp|ha - s;.|
|000051a0| 09 09 09 2f 2f 09 72 65 | 74 75 72 6e 20 74 68 65 |...//.re|turn the|
|000051b0| 20 66 69 6e 61 6c 20 70 | 61 72 74 20 6f 66 20 74 | final p|art of t|
|000051c0| 68 65 20 4e 53 74 72 69 | 6e 67 20 22 73 22 20 74 |he NStri|ng "s" t|
|000051d0| 68 61 74 20 72 65 6d 61 | 69 6e 73 0d 09 09 09 2f |hat rema|ins..../|
|000051e0| 2f 09 09 77 68 65 6e 20 | 61 6c 6c 20 6f 66 20 74 |/..when |all of t|
|000051f0| 68 65 20 69 6e 69 74 69 | 61 6c 20 6f 63 63 75 72 |he initi|al occur|
|00005200| 72 65 6e 63 65 73 20 6f | 66 20 74 68 65 20 63 6f |rences o|f the co|
|00005210| 6e 74 65 78 74 0d 09 09 | 09 2f 2f 09 09 68 61 76 |ntext...|.//..hav|
|00005220| 65 20 62 65 65 6e 20 73 | 74 72 69 70 70 65 64 2e |e been s|tripped.|
|00005230| 0d 09 09 09 0d 09 09 4e | 53 74 72 69 6e 67 20 6f |.......N|String o|
|00005240| 70 65 72 61 74 6f 72 2d | 20 28 63 6f 6e 73 74 20 |perator-| (const |
|00005250| 63 68 61 72 20 63 29 20 | 63 6f 6e 73 74 3b 09 09 |char c) |const;..|
|00005260| 09 09 09 09 09 09 09 09 | 09 2f 2f 09 09 74 20 3d |........|.//..t =|
|00005270| 20 73 20 2d 20 27 29 27 | 3b 0d 0d 09 09 4e 53 74 | s - ')'|;....NSt|
|00005280| 72 69 6e 67 20 6f 70 65 | 72 61 74 6f 72 2d 20 28 |ring ope|rator- (|
|00005290| 63 6f 6e 73 74 20 41 6c | 70 68 61 62 65 74 26 20 |const Al|phabet& |
|000052a0| 63 74 78 29 20 63 6f 6e | 73 74 3b 09 09 09 09 09 |ctx) con|st;.....|
|000052b0| 09 09 09 2f 2f 09 09 74 | 20 3d 20 73 20 2d 20 61 |...//..t| = s - a|
|000052c0| 6c 70 68 61 3b 0d 09 09 | 09 2f 2f 09 72 65 74 75 |lpha;...|.//.retu|
|000052d0| 72 6e 20 74 68 65 20 69 | 6e 69 74 69 61 6c 20 70 |rn the i|nitial p|
|000052e0| 61 72 74 20 6f 66 20 74 | 68 65 20 4e 53 74 72 69 |art of t|he NStri|
|000052f0| 6e 67 20 74 68 61 74 20 | 72 65 6d 61 69 6e 73 0d |ng that |remains.|
|00005300| 09 09 09 2f 2f 09 09 77 | 68 65 6e 20 61 6c 6c 20 |...//..w|hen all |
|00005310| 6f 66 20 74 68 65 20 66 | 69 6e 61 6c 20 6f 63 63 |of the f|inal occ|
|00005320| 75 72 72 65 6e 63 65 73 | 20 6f 66 20 74 68 65 20 |urrences| of the |
|00005330| 63 6f 6e 74 65 78 74 0d | 09 09 09 2f 2f 09 09 68 |context.|...//..h|
|00005340| 61 76 65 20 62 65 65 6e | 20 73 74 72 69 70 70 65 |ave been| strippe|
|00005350| 64 2e 0d 09 09 09 0d 09 | 09 4e 53 74 72 69 6e 67 |d.......|.NString|
|00005360| 26 20 6f 70 65 72 61 74 | 6f 72 2d 3d 20 28 63 6f |& operat|or-= (co|
|00005370| 6e 73 74 20 63 68 61 72 | 20 63 29 3b 09 09 09 09 |nst char| c);....|
|00005380| 09 09 09 09 09 09 09 2f | 2f 09 09 73 20 2d 3d 20 |......./|/..s -= |
|00005390| 27 30 27 3b 0d 0d 09 09 | 4e 53 74 72 69 6e 67 26 |'0';....|NString&|
|000053a0| 20 6f 70 65 72 61 74 6f | 72 2d 3d 20 28 63 6f 6e | operato|r-= (con|
|000053b0| 73 74 20 41 6c 70 68 61 | 62 65 74 26 20 63 74 78 |st Alpha|bet& ctx|
|000053c0| 29 3b 09 09 09 09 09 09 | 09 09 09 2f 2f 09 09 73 |);......|...//..s|
|000053d0| 20 2d 3d 20 61 6c 70 68 | 61 3b 0d 09 09 09 2f 2f | -= alph|a;....//|
|000053e0| 09 72 65 6d 6f 76 65 20 | 61 6c 6c 20 6f 66 20 74 |.remove |all of t|
|000053f0| 68 65 20 69 6e 69 74 69 | 61 6c 20 6f 63 63 75 72 |he initi|al occur|
|00005400| 72 65 6e 63 65 73 20 6f | 66 20 74 68 65 20 63 6f |rences o|f the co|
|00005410| 6e 74 65 78 74 0d 09 09 | 09 2f 2f 09 09 66 72 6f |ntext...|.//..fro|
|00005420| 6d 20 74 68 65 20 4e 53 | 74 72 69 6e 67 2e 0d 0d |m the NS|tring...|
|00005430| 09 09 2f 2a 2d 2d 2d 2d | 2d 2d 2d 2d 20 43 6f 6e |../*----|---- Con|
|00005440| 74 65 78 74 2d 72 65 6c | 61 74 65 64 20 74 65 73 |text-rel|ated tes|
|00005450| 74 73 20 2d 2d 2d 2d 2d | 2d 2d 2d 2a 2f 0d 0d 09 |ts -----|---*/...|
|00005460| 09 69 6e 6c 69 6e 65 20 | 69 6e 74 20 73 74 61 72 |.inline |int star|
|00005470| 74 73 77 69 74 68 20 28 | 63 6f 6e 73 74 20 63 68 |tswith (|const ch|
|00005480| 61 72 20 2a 63 6f 6e 74 | 65 78 74 29 20 63 6f 6e |ar *cont|ext) con|
|00005490| 73 74 3b 09 09 09 09 09 | 09 09 2f 2f 09 09 69 66 |st;.....|..//..if|
|000054a0| 20 28 73 2e 73 74 61 72 | 74 73 77 69 74 68 28 22 | (s.star|tswith("|
|000054b0| 72 65 70 65 61 74 22 29 | 29 20 2e 2e 2e 0d 0d 09 |repeat")|) ......|
|000054c0| 09 69 6e 6c 69 6e 65 20 | 69 6e 74 20 73 74 61 72 |.inline |int star|
|000054d0| 74 73 77 69 74 68 20 28 | 63 6f 6e 73 74 20 63 68 |tswith (|const ch|
|000054e0| 61 72 20 63 6f 6e 74 65 | 78 74 29 20 63 6f 6e 73 |ar conte|xt) cons|
|000054f0| 74 3b 09 09 09 09 09 09 | 09 09 2f 2f 09 09 69 66 |t;......|..//..if|
|00005500| 20 28 73 2e 73 74 61 72 | 74 73 77 69 74 68 28 27 | (s.star|tswith('|
|00005510| 51 27 29 29 20 2e 2e 2e | 0d 0d 09 09 69 6e 6c 69 |Q')) ...|....inli|
|00005520| 6e 65 20 69 6e 74 20 73 | 74 61 72 74 73 77 69 74 |ne int s|tartswit|
|00005530| 68 20 28 63 6f 6e 73 74 | 20 4e 53 74 72 69 6e 67 |h (const| NString|
|00005540| 26 20 63 6f 6e 74 65 78 | 74 29 20 63 6f 6e 73 74 |& contex|t) const|
|00005550| 3b 09 09 09 09 09 09 2f | 2f 09 09 69 66 20 28 73 |;....../|/..if (s|
|00005560| 2e 73 74 61 72 74 73 77 | 69 74 68 28 74 29 29 20 |.startsw|ith(t)) |
|00005570| 2e 2e 2e 0d 0d 09 09 69 | 6e 6c 69 6e 65 20 69 6e |.......i|nline in|
|00005580| 74 20 73 74 61 72 74 73 | 77 69 74 68 20 28 63 6f |t starts|with (co|
|00005590| 6e 73 74 20 41 6c 70 68 | 61 62 65 74 26 20 63 6f |nst Alph|abet& co|
|000055a0| 6e 74 65 78 74 29 20 63 | 6f 6e 73 74 3b 09 09 09 |ntext) c|onst;...|
|000055b0| 09 09 09 2f 2f 09 09 69 | 66 20 28 73 2e 73 74 61 |...//..i|f (s.sta|
|000055c0| 72 74 73 77 69 74 68 28 | 61 6c 70 68 61 29 29 20 |rtswith(|alpha)) |
|000055d0| 2e 2e 2e 0d 09 09 09 2f | 2f 09 72 65 74 75 72 6e |......./|/.return|
|000055e0| 20 6e 6f 6e 2d 7a 65 72 | 6f 20 69 66 20 74 68 65 | non-zer|o if the|
|000055f0| 20 4e 53 74 72 69 6e 67 | 20 73 74 61 72 74 73 20 | NString| starts |
|00005600| 77 69 74 68 20 74 68 65 | 20 67 69 76 65 6e 20 63 |with the| given c|
|00005610| 6f 6e 74 65 78 74 2c 0d | 09 09 09 2f 2f 09 09 7a |ontext,.|...//..z|
|00005620| 65 72 6f 20 6f 74 68 65 | 72 77 69 73 65 2e 0d 0d |ero othe|rwise...|
|00005630| 0d 09 09 69 6e 74 20 65 | 6e 64 73 77 69 74 68 20 |...int e|ndswith |
|00005640| 28 63 6f 6e 73 74 20 63 | 68 61 72 20 2a 63 6f 6e |(const c|har *con|
|00005650| 74 65 78 74 29 20 63 6f | 6e 73 74 3b 09 09 09 09 |text) co|nst;....|
|00005660| 09 09 09 09 09 09 2f 2f | 09 09 69 66 20 28 73 2e |......//|..if (s.|
|00005670| 65 6e 64 73 77 69 74 68 | 28 22 72 65 70 65 61 74 |endswith|("repeat|
|00005680| 22 29 29 20 2e 2e 2e 0d | 0d 09 09 69 6e 6c 69 6e |")) ....|...inlin|
|00005690| 65 20 69 6e 74 20 65 6e | 64 73 77 69 74 68 20 28 |e int en|dswith (|
|000056a0| 63 6f 6e 73 74 20 63 68 | 61 72 20 63 6f 6e 74 65 |const ch|ar conte|
|000056b0| 78 74 29 20 63 6f 6e 73 | 74 3b 09 09 09 09 09 09 |xt) cons|t;......|
|000056c0| 09 09 2f 2f 09 09 69 66 | 20 28 73 2e 65 6e 64 73 |..//..if| (s.ends|
|000056d0| 77 69 74 68 28 27 51 27 | 29 29 20 2e 2e 2e 0d 0d |with('Q'|)) .....|
|000056e0| 09 09 69 6e 6c 69 6e 65 | 20 69 6e 74 20 65 6e 64 |..inline| int end|
|000056f0| 73 77 69 74 68 20 28 63 | 6f 6e 73 74 20 4e 53 74 |swith (c|onst NSt|
|00005700| 72 69 6e 67 26 20 63 6f | 6e 74 65 78 74 29 20 63 |ring& co|ntext) c|
|00005710| 6f 6e 73 74 3b 09 09 09 | 09 09 09 09 2f 2f 09 09 |onst;...|....//..|
|00005720| 69 66 20 28 73 2e 65 6e | 64 73 77 69 74 68 28 74 |if (s.en|dswith(t|
|00005730| 29 29 20 2e 2e 2e 0d 0d | 09 09 69 6e 6c 69 6e 65 |)) .....|..inline|
|00005740| 20 69 6e 74 20 65 6e 64 | 73 77 69 74 68 20 28 63 | int end|swith (c|
|00005750| 6f 6e 73 74 20 41 6c 70 | 68 61 62 65 74 26 20 63 |onst Alp|habet& c|
|00005760| 6f 6e 74 65 78 74 29 20 | 63 6f 6e 73 74 3b 09 09 |ontext) |const;..|
|00005770| 09 09 09 09 2f 2f 09 09 | 69 66 20 28 73 2e 65 6e |....//..|if (s.en|
|00005780| 64 73 77 69 74 68 28 61 | 6c 70 68 61 29 29 20 2e |dswith(a|lpha)) .|
|00005790| 2e 2e 0d 09 09 09 2f 2f | 09 72 65 74 75 72 6e 20 |......//|.return |
|000057a0| 6e 6f 6e 2d 7a 65 72 6f | 20 69 66 20 74 68 65 20 |non-zero| if the |
|000057b0| 4e 53 74 72 69 6e 67 20 | 65 6e 64 73 20 77 69 74 |NString |ends wit|
|000057c0| 68 20 74 68 65 20 67 69 | 76 65 6e 20 63 6f 6e 74 |h the gi|ven cont|
|000057d0| 65 78 74 2c 0d 09 09 09 | 2f 2f 09 09 7a 65 72 6f |ext,....|//..zero|
|000057e0| 20 6f 74 68 65 72 77 69 | 73 65 2e 0d 0d 0d 09 09 | otherwi|se......|
|000057f0| 69 6e 6c 69 6e 65 20 69 | 6e 74 20 63 6f 6e 74 61 |inline i|nt conta|
|00005800| 69 6e 73 20 28 63 6f 6e | 73 74 20 63 68 61 72 20 |ins (con|st char |
|00005810| 2a 63 6f 6e 74 65 78 74 | 29 20 63 6f 6e 73 74 3b |*context|) const;|
|00005820| 09 09 09 09 09 09 09 09 | 2f 2f 09 09 69 66 20 28 |........|//..if (|
|00005830| 73 2e 63 6f 6e 74 61 69 | 6e 73 28 22 74 61 6b 65 |s.contai|ns("take|
|00005840| 22 29 29 20 2e 2e 2e 0d | 0d 09 09 69 6e 6c 69 6e |")) ....|...inlin|
|00005850| 65 20 69 6e 74 20 63 6f | 6e 74 61 69 6e 73 20 28 |e int co|ntains (|
|00005860| 63 6f 6e 73 74 20 63 68 | 61 72 20 63 6f 6e 74 65 |const ch|ar conte|
|00005870| 78 74 29 20 63 6f 6e 73 | 74 3b 09 09 09 09 09 09 |xt) cons|t;......|
|00005880| 09 09 2f 2f 09 09 69 66 | 20 28 73 2e 63 6f 6e 74 |..//..if| (s.cont|
|00005890| 61 69 6e 73 28 27 3c 27 | 29 29 20 2e 2e 2e 0d 0d |ains('<'|)) .....|
|000058a0| 09 09 69 6e 6c 69 6e 65 | 20 69 6e 74 20 63 6f 6e |..inline| int con|
|000058b0| 74 61 69 6e 73 20 28 63 | 6f 6e 73 74 20 4e 53 74 |tains (c|onst NSt|
|000058c0| 72 69 6e 67 26 20 63 6f | 6e 74 65 78 74 29 20 63 |ring& co|ntext) c|
|000058d0| 6f 6e 73 74 3b 09 09 09 | 09 09 09 09 2f 2f 09 09 |onst;...|....//..|
|000058e0| 69 66 20 28 73 2e 63 6f | 6e 74 61 69 6e 73 28 74 |if (s.co|ntains(t|
|000058f0| 29 29 20 2e 2e 2e 0d 0d | 09 09 69 6e 6c 69 6e 65 |)) .....|..inline|
|00005900| 20 69 6e 74 20 63 6f 6e | 74 61 69 6e 73 20 28 63 | int con|tains (c|
|00005910| 6f 6e 73 74 20 41 6c 70 | 68 61 62 65 74 26 20 63 |onst Alp|habet& c|
|00005920| 6f 6e 74 65 78 74 29 20 | 63 6f 6e 73 74 3b 09 09 |ontext) |const;..|
|00005930| 09 09 09 09 2f 2f 09 09 | 69 66 20 28 73 2e 63 6f |....//..|if (s.co|
|00005940| 6e 74 61 69 6e 73 28 61 | 6c 70 68 61 29 29 20 2e |ntains(a|lpha)) .|
|00005950| 2e 2e 0d 09 09 09 2f 2f | 09 72 65 74 75 72 6e 20 |......//|.return |
|00005960| 6e 6f 6e 2d 7a 65 72 6f | 20 69 66 20 74 68 65 20 |non-zero| if the |
|00005970| 4e 53 74 72 69 6e 67 20 | 28 65 6e 74 69 72 65 6c |NString |(entirel|
|00005980| 79 29 20 63 6f 6e 74 61 | 69 6e 73 20 74 68 65 20 |y) conta|ins the |
|00005990| 67 69 76 65 6e 20 63 6f | 6e 74 65 78 74 2c 0d 09 |given co|ntext,..|
|000059a0| 09 09 2f 2f 09 09 7a 65 | 72 6f 20 6f 74 68 65 72 |..//..ze|ro other|
|000059b0| 77 69 73 65 2e 20 49 6e | 20 74 68 65 20 63 61 73 |wise. In| the cas|
|000059c0| 65 20 6f 66 20 61 6e 20 | 61 6c 70 68 61 62 65 74 |e of an |alphabet|
|000059d0| 2c 20 74 68 69 73 20 6d | 65 61 6e 73 20 74 68 61 |, this m|eans tha|
|000059e0| 74 0d 09 09 09 2f 2f 09 | 09 45 56 45 52 59 20 6c |t....//.|.EVERY l|
|000059f0| 65 74 74 65 72 20 6f 66 | 20 74 68 65 20 61 6c 70 |etter of| the alp|
|00005a00| 68 61 62 65 74 20 6d 75 | 73 74 20 62 65 20 63 6f |habet mu|st be co|
|00005a10| 6e 74 61 69 6e 65 64 20 | 69 6e 20 74 68 65 20 4e |ntained |in the N|
|00005a20| 53 74 72 69 6e 67 2e 0d | 09 09 09 2f 2f 20 49 66 |String..|...// If|
|00005a30| 20 22 63 6f 6e 74 65 78 | 74 22 20 69 73 20 61 6e | "contex|t" is an|
|00005a40| 20 65 6d 70 74 79 20 61 | 6c 70 68 61 62 65 74 2c | empty a|lphabet,|
|00005a50| 20 6e 6f 6e 2d 7a 65 72 | 6f 20 69 73 20 72 65 74 | non-zer|o is ret|
|00005a60| 75 72 6e 65 64 2e 0d 0d | 0d 09 09 69 6e 6c 69 6e |urned...|...inlin|
|00005a70| 65 20 69 6e 74 20 64 69 | 73 6a 6f 69 6e 74 65 64 |e int di|sjointed|
|00005a80| 20 28 63 6f 6e 73 74 20 | 41 6c 70 68 61 62 65 74 | (const |Alphabet|
|00005a90| 26 20 61 6c 70 68 61 29 | 20 63 6f 6e 73 74 3b 09 |& alpha)| const;.|
|00005aa0| 09 09 09 09 09 09 2f 2f | 09 09 69 66 20 28 73 2e |......//|..if (s.|
|00005ab0| 64 69 73 6a 6f 69 6e 74 | 65 64 28 61 6c 70 68 61 |disjoint|ed(alpha|
|00005ac0| 29 29 20 2e 2e 2e 0d 09 | 09 09 2f 2f 20 72 65 74 |)) .....|..// ret|
|00005ad0| 75 72 6e 20 6e 6f 6e 2d | 7a 65 72 6f 20 69 66 66 |urn non-|zero iff|
|00005ae0| 20 6e 6f 6e 65 20 6f 66 | 20 74 68 65 20 61 6c 70 | none of| the alp|
|00005af0| 68 61 62 65 74 27 73 20 | 6c 65 74 74 65 72 73 0d |habet's |letters.|
|00005b00| 09 09 09 2f 2f 09 09 6f | 63 63 75 72 73 20 69 6e |...//..o|ccurs in|
|00005b10| 20 74 68 65 20 4e 53 74 | 72 69 6e 67 2c 20 7a 65 | the NSt|ring, ze|
|00005b20| 72 6f 20 6f 74 68 65 72 | 77 69 73 65 2e 0d 09 09 |ro other|wise....|
|00005b30| 09 2f 2f 20 49 66 20 22 | 61 6c 70 68 61 22 20 69 |.// If "|alpha" i|
|00005b40| 73 20 65 6d 70 74 79 2c | 20 6e 6f 6e 2d 7a 65 72 |s empty,| non-zer|
|00005b50| 6f 20 69 73 20 72 65 74 | 75 72 6e 65 64 2e 0d 0d |o is ret|urned...|
|00005b60| 0d 09 09 2f 2a 2d 2d 2d | 2d 2d 2d 2d 2d 20 49 6e |.../*---|----- In|
|00005b70| 70 75 74 20 2f 20 4f 75 | 74 70 75 74 20 2d 2d 2d |put / Ou|tput ---|
|00005b80| 2d 2d 2d 2d 2d 2a 2f 0d | 0d 09 09 66 72 69 65 6e |-----*/.|...frien|
|00005b90| 64 20 6f 73 74 72 65 61 | 6d 26 20 6f 70 65 72 61 |d ostrea|m& opera|
|00005ba0| 74 6f 72 3c 3c 20 28 6f | 73 74 72 65 61 6d 26 20 |tor<< (o|stream& |
|00005bb0| 74 68 65 53 74 72 65 61 | 6d 2c 20 63 6f 6e 73 74 |theStrea|m, const|
|00005bc0| 20 4e 53 74 72 69 6e 67 | 26 20 74 68 65 53 74 72 | NString|& theStr|
|00005bd0| 69 6e 67 29 3b 09 2f 2f | 09 09 63 6f 75 74 20 3c |ing);.//|..cout <|
|00005be0| 3c 20 73 3b 0d 09 09 09 | 2f 2f 20 6f 75 74 70 75 |< s;....|// outpu|
|00005bf0| 74 20 74 68 65 20 4e 53 | 74 72 69 6e 67 20 6f 6e |t the NS|tring on|
|00005c00| 74 6f 20 74 68 65 20 73 | 74 72 65 61 6d 20 22 74 |to the s|tream "t|
|00005c10| 68 65 53 74 72 65 61 6d | 22 2e 0d 09 09 09 2f 2f |heStream|".....//|
|00005c20| 20 46 69 65 6c 64 20 77 | 69 64 74 68 20 61 6e 64 | Field w|idth and|
|00005c30| 20 66 69 6c 6c 20 63 68 | 61 72 61 63 74 65 72 20 | fill ch|aracter |
|00005c40| 61 72 65 20 73 75 70 70 | 6f 72 74 65 64 20 69 6e |are supp|orted in|
|00005c50| 20 74 68 65 20 73 61 6d | 65 20 77 61 79 0d 09 09 | the sam|e way...|
|00005c60| 09 2f 2f 09 09 61 73 20 | 66 6f 72 20 43 2d 73 74 |.//..as |for C-st|
|00005c70| 72 69 6e 67 73 2e 0d 0d | 09 09 66 72 69 65 6e 64 |rings...|..friend|
|00005c80| 20 69 73 74 72 65 61 6d | 26 20 6f 70 65 72 61 74 | istream|& operat|
|00005c90| 6f 72 3e 3e 20 28 69 73 | 74 72 65 61 6d 26 20 74 |or>> (is|tream& t|
|00005ca0| 68 65 53 74 72 65 61 6d | 2c 20 4e 53 74 72 69 6e |heStream|, NStrin|
|00005cb0| 67 26 20 74 68 65 53 74 | 72 69 6e 67 29 3b 09 09 |g& theSt|ring);..|
|00005cc0| 09 2f 2f 09 09 63 69 6e | 20 3e 3e 20 73 3b 0d 09 |.//..cin| >> s;..|
|00005cd0| 09 09 2f 2f 20 73 6b 69 | 70 20 77 68 69 74 65 73 |..// ski|p whites|
|00005ce0| 70 61 63 65 2c 20 74 68 | 65 6e 20 69 6e 70 75 74 |pace, th|en input|
|00005cf0| 20 61 20 63 68 61 72 61 | 63 74 65 72 20 73 74 72 | a chara|cter str|
|00005d00| 69 6e 67 20 66 72 6f 6d | 20 22 74 68 65 53 74 72 |ing from| "theStr|
|00005d10| 65 61 6d 22 0d 09 09 09 | 2f 2f 09 09 61 6e 64 20 |eam"....|//..and |
|00005d20| 73 74 6f 72 65 20 69 74 | 20 69 6e 20 22 74 68 65 |store it| in "the|
|00005d30| 53 74 72 69 6e 67 22 2e | 20 57 68 69 74 65 73 70 |String".| Whitesp|
|00005d40| 61 63 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 74 68 |ace foll|owing th|
|00005d50| 65 20 73 74 72 69 6e 67 | 0d 09 09 09 2f 2f 09 09 |e string|....//..|
|00005d60| 69 73 20 74 72 65 61 74 | 65 64 20 61 73 20 74 65 |is treat|ed as te|
|00005d70| 72 6d 69 6e 61 74 6f 72 | 20 61 6e 64 20 6c 65 66 |rminator| and lef|
|00005d80| 74 20 6f 6e 20 74 68 65 | 20 73 74 72 65 61 6d 20 |t on the| stream |
|00005d90| 66 6f 72 20 73 75 62 73 | 65 71 75 65 6e 74 20 72 |for subs|equent r|
|00005da0| 65 61 64 73 2e 0d 09 09 | 09 2f 2f 20 54 68 65 20 |eads....|.// The |
|00005db0| 4e 55 4c 20 63 68 61 72 | 61 63 74 65 72 20 69 73 |NUL char|acter is|
|00005dc0| 20 63 6f 6e 73 69 64 65 | 72 65 64 20 77 68 69 74 | conside|red whit|
|00005dd0| 65 73 70 61 63 65 20 69 | 6e 20 74 68 69 73 20 63 |espace i|n this c|
|00005de0| 6f 6e 74 65 78 74 2e 0d | 09 09 09 2f 2f 20 46 69 |ontext..|...// Fi|
|00005df0| 65 6c 64 20 77 69 64 74 | 68 20 61 6e 64 20 74 68 |eld widt|h and th|
|00005e00| 65 20 22 69 6f 73 3a 3a | 73 6b 69 70 77 73 22 20 |e "ios::|skipws" |
|00005e10| 66 6c 61 67 20 61 72 65 | 20 63 75 72 72 65 6e 74 |flag are| current|
|00005e20| 6c 79 20 69 67 6e 6f 72 | 65 64 2e 0d 09 09 09 2f |ly ignor|ed...../|
|00005e30| 2f 20 49 66 20 74 68 65 | 20 6f 70 65 72 61 74 6f |/ If the| operato|
|00005e40| 72 20 69 73 20 75 73 65 | 64 20 6f 6e 20 61 20 73 |r is use|d on a s|
|00005e50| 74 72 65 61 6d 20 74 68 | 61 74 20 69 73 20 6e 6f |tream th|at is no|
|00005e60| 74 20 69 6e 20 67 6f 6f | 64 20 63 6f 6e 64 69 74 |t in goo|d condit|
|00005e70| 69 6f 6e 2c 0d 09 09 09 | 2f 2f 09 09 74 68 65 20 |ion,....|//..the |
|00005e80| 6f 70 65 72 61 74 69 6f | 6e 20 69 73 20 61 20 6e |operatio|n is a n|
|00005e90| 75 6c 6c 20 6f 70 65 72 | 61 74 69 6f 6e 20 61 6e |ull oper|ation an|
|00005ea0| 64 20 22 74 68 65 53 74 | 72 69 6e 67 22 20 69 73 |d "theSt|ring" is|
|00005eb0| 20 6c 65 66 74 20 75 6e | 6d 6f 64 69 66 69 65 64 | left un|modified|
|00005ec0| 2e 0d 09 09 09 2f 2f 20 | 4e 6f 74 65 20 74 68 61 |.....// |Note tha|
|00005ed0| 74 20 61 20 63 61 6c 6c | 20 6c 69 6b 65 20 22 63 |t a call| like "c|
|00005ee0| 69 6e 20 3e 3e 20 73 22 | 20 69 73 20 70 65 72 66 |in >> s"| is perf|
|00005ef0| 65 63 74 6c 79 20 73 61 | 66 65 20 69 66 20 22 73 |ectly sa|fe if "s|
|00005f00| 22 20 69 73 20 61 6e 20 | 4e 53 74 72 69 6e 67 2c |" is an |NString,|
|00005f10| 0d 09 09 09 2f 2f 09 09 | 61 73 20 4e 53 74 72 69 |....//..|as NStri|
|00005f20| 6e 67 73 20 64 79 6e 61 | 6d 69 63 61 6c 6c 79 20 |ngs dyna|mically |
|00005f30| 61 6c 6c 6f 63 61 74 65 | 20 74 68 65 20 6e 65 65 |allocate| the nee|
|00005f40| 64 65 64 20 6d 65 6d 6f | 72 79 2e 0d 09 09 09 0d |ded memo|ry......|
|00005f50| 09 09 66 72 69 65 6e 64 | 20 69 73 74 72 65 61 6d |..friend| istream|
|00005f60| 26 20 67 65 74 20 28 69 | 73 74 72 65 61 6d 26 20 |& get (i|stream& |
|00005f70| 74 68 65 53 74 72 65 61 | 6d 2c 20 4e 53 74 72 69 |theStrea|m, NStri|
|00005f80| 6e 67 26 20 74 68 65 53 | 74 72 69 6e 67 2c 0d 09 |ng& theS|tring,..|
|00005f90| 09 09 09 09 09 09 09 09 | 09 63 6f 6e 73 74 20 75 |........|.const u|
|00005fa0| 6e 73 69 67 6e 65 64 20 | 6c 6f 6e 67 20 69 6e 74 |nsigned |long int|
|00005fb0| 20 6d 61 78 4c 65 6e 67 | 74 68 2c 20 63 6f 6e 73 | maxLeng|th, cons|
|00005fc0| 74 20 63 68 61 72 20 74 | 65 72 6d 69 6e 61 74 6f |t char t|erminato|
|00005fd0| 72 20 3d 20 27 5c 6e 27 | 29 3b 0d 09 09 09 2f 2f |r = '\n'|);....//|
|00005fe0| 20 69 6e 70 75 74 20 63 | 68 61 72 61 63 74 65 72 | input c|haracter|
|00005ff0| 73 20 66 72 6f 6d 20 74 | 68 65 20 73 74 72 65 61 |s from t|he strea|
|00006000| 6d 20 22 74 68 65 53 74 | 72 65 61 6d 22 20 69 6e |m "theSt|ream" in|
|00006010| 74 6f 20 74 68 65 20 4e | 53 74 72 69 6e 67 20 22 |to the N|String "|
|00006020| 74 68 65 53 74 72 69 6e | 67 22 2c 0d 09 09 09 2f |theStrin|g",..../|
|00006030| 2f 09 09 62 75 74 20 64 | 6f 6e 27 74 20 6d 61 6b |/..but d|on't mak|
|00006040| 65 20 74 68 65 20 73 74 | 72 69 6e 67 20 61 6e 79 |e the st|ring any|
|00006050| 20 6c 6f 6e 67 65 72 20 | 74 68 61 6e 20 22 6d 61 | longer |than "ma|
|00006060| 78 4c 65 6e 67 74 68 22 | 2e 0d 09 09 09 2f 2f 09 |xLength"|.....//.|
|00006070| 09 49 66 20 22 6d 61 78 | 4c 65 6e 67 74 68 22 20 |.If "max|Length" |
|00006080| 3d 3d 20 30 2c 20 74 68 | 69 73 20 63 6f 6e 73 74 |== 0, th|is const|
|00006090| 72 61 69 6e 74 20 69 73 | 20 69 67 6e 6f 72 65 64 |raint is| ignored|
|000060a0| 2e 0d 09 09 09 2f 2f 20 | 49 66 20 61 20 22 74 65 |.....// |If a "te|
|000060b0| 72 6d 69 6e 61 74 6f 72 | 22 20 63 68 61 72 61 63 |rminator|" charac|
|000060c0| 74 65 72 20 69 73 20 65 | 6e 63 6f 75 6e 74 65 72 |ter is e|ncounter|
|000060d0| 65 64 2c 20 69 74 20 69 | 73 20 6c 65 66 74 20 6f |ed, it i|s left o|
|000060e0| 6e 20 74 68 65 20 73 74 | 72 65 61 6d 20 66 6f 72 |n the st|ream for|
|000060f0| 0d 09 09 09 2f 2f 09 09 | 73 75 62 73 65 71 75 65 |....//..|subseque|
|00006100| 6e 74 20 72 65 61 64 73 | 20 61 6e 64 20 74 68 65 |nt reads| and the|
|00006110| 20 63 75 72 72 65 6e 74 | 20 69 6e 70 75 74 20 70 | current| input p|
|00006120| 72 6f 63 65 73 73 20 74 | 65 72 6d 69 6e 61 74 65 |rocess t|erminate|
|00006130| 73 2e 0d 09 09 09 2f 2f | 09 09 22 74 65 72 6d 69 |s.....//|.."termi|
|00006140| 6e 61 74 6f 72 22 20 6d | 61 79 20 62 65 20 73 65 |nator" m|ay be se|
|00006150| 74 20 74 6f 20 27 5c 30 | 27 2c 20 69 66 20 6e 6f |t to '\0|', if no|
|00006160| 20 73 70 65 63 69 61 6c | 20 74 65 72 6d 69 6e 61 | special| termina|
|00006170| 74 6f 72 20 63 68 61 72 | 61 63 74 65 72 20 69 73 |tor char|acter is|
|00006180| 0d 09 09 09 2f 2f 09 09 | 64 65 73 69 72 65 64 2e |....//..|desired.|
|00006190| 0d 09 09 09 2f 2f 20 57 | 68 69 74 65 73 70 61 63 |....// W|hitespac|
|000061a0| 65 20 69 73 20 74 72 65 | 61 74 65 64 20 61 73 20 |e is tre|ated as |
|000061b0| 61 6e 79 20 6f 74 68 65 | 72 20 63 68 61 72 61 63 |any othe|r charac|
|000061c0| 74 65 72 2e 0d 09 09 09 | 2f 2f 09 4e 55 4c 20 63 |ter.....|//.NUL c|
|000061d0| 68 61 72 61 63 74 65 72 | 73 20 70 72 65 63 65 64 |haracter|s preced|
|000061e0| 69 6e 67 20 75 73 65 66 | 75 6c 20 73 74 72 69 6e |ing usef|ul strin|
|000061f0| 67 20 64 61 74 61 20 61 | 72 65 20 73 6b 69 70 70 |g data a|re skipp|
|00006200| 65 64 2e 0d 09 09 09 2f | 2f 20 41 20 4e 55 4c 20 |ed...../|/ A NUL |
|00006210| 63 68 61 72 61 63 74 65 | 72 20 66 6f 6c 6c 6f 77 |characte|r follow|
|00006220| 69 6e 67 20 73 74 72 69 | 6e 67 20 64 61 74 61 20 |ing stri|ng data |
|00006230| 61 6c 77 61 79 73 20 61 | 63 74 73 20 6c 69 6b 65 |always a|cts like|
|00006240| 20 61 20 74 65 72 6d 69 | 6e 61 74 6f 72 2e 0d 09 | a termi|nator...|
|00006250| 09 09 2f 2f 20 49 66 20 | 74 68 65 20 66 75 6e 63 |..// If |the func|
|00006260| 74 69 6f 6e 20 69 73 20 | 75 73 65 64 20 6f 6e 20 |tion is |used on |
|00006270| 61 20 73 74 72 65 61 6d | 20 74 68 61 74 20 69 73 |a stream| that is|
|00006280| 20 6e 6f 74 20 69 6e 20 | 67 6f 6f 64 20 63 6f 6e | not in |good con|
|00006290| 64 69 74 69 6f 6e 2c 0d | 09 09 09 2f 2f 09 09 74 |dition,.|...//..t|
|000062a0| 68 65 20 6f 70 65 72 61 | 74 69 6f 6e 20 69 73 20 |he opera|tion is |
|000062b0| 61 20 6e 75 6c 6c 20 6f | 70 65 72 61 74 69 6f 6e |a null o|peration|
|000062c0| 20 61 6e 64 20 22 74 68 | 65 53 74 72 69 6e 67 22 | and "th|eString"|
|000062d0| 20 69 73 20 6c 65 66 74 | 20 75 6e 6d 6f 64 69 66 | is left| unmodif|
|000062e0| 69 65 64 2e 0d 0d 09 09 | 66 72 69 65 6e 64 20 69 |ied.....|friend i|
|000062f0| 6e 6c 69 6e 65 20 69 73 | 74 72 65 61 6d 26 20 67 |nline is|tream& g|
|00006300| 65 74 20 28 69 73 74 72 | 65 61 6d 26 20 74 68 65 |et (istr|eam& the|
|00006310| 53 74 72 65 61 6d 2c 20 | 4e 53 74 72 69 6e 67 26 |Stream, |NString&|
|00006320| 20 74 68 65 53 74 72 69 | 6e 67 2c 20 63 6f 6e 73 | theStri|ng, cons|
|00006330| 74 20 63 68 61 72 20 74 | 65 72 6d 69 6e 61 74 6f |t char t|erminato|
|00006340| 72 20 3d 20 27 5c 6e 27 | 29 3b 0d 09 09 09 2f 2f |r = '\n'|);....//|
|00006350| 20 65 71 75 69 76 61 6c | 65 6e 74 20 74 6f 20 74 | equival|ent to t|
|00006360| 68 65 20 70 72 65 63 65 | 64 69 6e 67 20 22 67 65 |he prece|ding "ge|
|00006370| 74 28 29 22 20 66 75 6e | 63 74 69 6f 6e 2c 20 62 |t()" fun|ction, b|
|00006380| 75 74 20 77 69 74 68 6f | 75 74 20 73 74 72 69 6e |ut witho|ut strin|
|00006390| 67 20 6c 65 6e 67 74 68 | 20 6c 69 6d 69 74 61 74 |g length| limitat|
|000063a0| 69 6f 6e 2e 0d 0d 0d 09 | 09 69 6e 6c 69 6e 65 20 |ion.....|.inline |
|000063b0| 4e 53 74 72 69 6e 67 26 | 20 6f 70 65 72 61 74 6f |NString&| operato|
|000063c0| 72 3c 3c 20 28 63 6f 6e | 73 74 20 63 68 61 72 20 |r<< (con|st char |
|000063d0| 2a 73 29 3b 0d 09 09 69 | 6e 6c 69 6e 65 20 4e 53 |*s);...i|nline NS|
|000063e0| 74 72 69 6e 67 26 20 6f | 70 65 72 61 74 6f 72 3c |tring& o|perator<|
|000063f0| 3c 20 28 63 6f 6e 73 74 | 20 4e 53 74 72 69 6e 67 |< (const| NString|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.